Hey @mirco, I had this exact problem. In addition to what Martin has suggested, can you try doing this in ARC? curl works if you’re ok with using a curl, but if you want to post pure JSON data into the body, I have had better luck using ARC than using Postman. In my research, I saw a couple of forum posts indicating that Postman uses a special header for form-data, and that 200 OK for ERPNext sometimes means “resource not found,” which is obviously not a great error code to use because it normally means “you did it!”
I find that ARC throws detailed exceptions including the Python args that failed, so I prefer to use it for developing our API with ERPNext in particular. Let me know if you have the same results!
It’s really important when posting code fragments to use the forum’s code formatting. In order to test your Postman generated curl I had to search and replace all of these ‘ for these ', all of these “ for these " and all of these – for these --.
In other words, this:
curl --location --request POST ‘https:// sub.example.com /api/resource/Lead/’
–header ‘Authorization: token 9efb53433acb7ba*:xxxxxxxxxxxx*’
–header ‘Content-Type: application/json’
–header ‘Cookie: sid=Guest; system_user=yes; full_name=Guest; user_id=Guest; user_image=’
–data-raw ‘[{“notes":“Notes”,“phone”:“123456789”,“email_id”:"exmaple@test.com”,“lead_name”:“John”,“address_desc”:“New York”}]’
POSTing a Lead does nothing except behave like a GET.
To solve the 301 error you need to investigate the --location switch in curl, then find out how to get ARC to emit that switch. If you remove --location from the Postman generated curl you will get a 301 error.
Worse – is an API that returns HTML error messages! It’s hard to express in polite terms how bad that is.
HTTP & HTML were created to solve the problem of human beings trying to get at remote data in a friendly way. With that becoming standard, APIs had to be created to solve the problem of software having to parse human friendly info in order to get at the same data.
Frappe’s brilliant step forward has been to insist that software MUST parse human friendly error messages to find out how to react when things going wrong! Feh. That is so last millenium.