The piece of code you wrote, take long way to reach production server. And usually different errors occurs when we take code one server to other. I test restful service code C# class and call it form X++ code multiple times and it works perfectly fine on QA. But when I took same code to Uat server it started throw following error
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
And why the same code works perfectly on DEV while calling same service method UAT throw errors.
Any how I found that I missed the request. Method = Post in code snippet I used for service call. something like
request.Method = “POST”;