I am using HttpWebRequests and I am trying to fire a PUT request with a JSON body that is required for updating the information of a user. Whenever I am doing a PUT request. I am seeing two errors on it. The error and the exceptions are as follow: 1.) A GET request has to be made in order to make a PUT request(as the resolution I applied a GET method before the PUT method and I used the same HttpWebRequest object to modify the call as PUT but that is getting stuck on an exception that says “System.InvalidOperationException” )
2.) System.InvalidOperationException is not letting me add a request body with a PUT request.
3.) Parameters being provided with the requests are Method, Accept(Content-Type), Headers(Xrfkey), client issued certificate, X-Qlik-User(userDirectory and userId), writing the request stream with stream.write(jsonData, 0, jsonData.Length)
I personally find the WebClient class to be easier to work with as it provides some useful abstractions on top of the requests that fit well with for instance Qliks REST APIs.
Your observation on having to do a "GET" before doing a "PUT" is correct though. When you do the first Get, you will get a cookie from Qlik that is used for authentication, and that cookie needs to be included in any following non-get operations. I actually had that flow automated in that project I linked to, but realized that I never pushed my fix. Thanks for pointing that out!