I’ve a problem with a Webservice Call. I want to update an entity so I use the ‘PUT’ Method and the HttpWebRequestMgt Codeunit (1297) to create and send the request.
It’s working fine in Postman, but in NAV (2018) I get an HttpErrorCode 400.
I’ve also created a GET Request with the same url and it’s working fine. So I’ve basically only added a JSON-Body and changed the HTTP-Method.
So i assume that i forgot something…here’s the code i’m using:
Not a solution but more a suggestion -
I haven’t used NAV 2018 so I can’t test your code.
If you have a request that works and one that doesn’t, capture the raw request from the postman console and compare it to the request you’ve made above. Use a test service like requestbin or a variant of it to capture your requests generated in code and compare.
You just want something to log your HTTP requests. Just make sure to be careful on what you send for auth if you are not running the logging locally. A simple google search is your friend for a tool.
Other ideas:
verify HttpMethod in your code.
Write the URI out and make sure it matches postman
check for case sensitivity in the URL params. (I’ve seen worse…)
V 19.0 has SetJSONContent on HttpWebRequest - not sure if it’s in your version.
Sorry, for the late response, but i was working on other topics the last weeks.
Today finally I found some time to spend again with this problem and it paid off. I finally found the solution for my problem. I looked at some examples on the net and instead of using:
The difference between these two functions is that in the first row the body is send UTF-8 encoded and in the second it’s ASCII encoded.
Here the code from CU 1297 “Http Web Request Mgt.”: