Order Update PUT API in VB.net not working
-
I am trying to update the STATUS of a Woocommerce order using the RestAPI in VB.NET
It works in postman, but I can not figure out what is wrong in .NETHere is my code:
`Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls Or Net.SecurityProtocolType.Ssl3 Or Net.SecurityProtocolType.Tls11 Or Net.SecurityProtocolType.Tls12
Dim client = New RestClient(“https://staging3.reekooz.com/wp-json/wc/v3/orders/227175”)
Dim request = New RestRequest(Method.PUT)
request.AddHeader(“Content-Type”, “application/json”)
request.AddHeader(“Authorization”, “Basic correctString”)
request.AddHeader(“Content-Type”, “text/plain”)
Dim qu As String = Chr(34)
Dim txt As String = “{” & qu & “status” & qu & “: ” & qu & “preparing” & qu & “}”
Response.Write(txt & br & br & br)
request.AddParameter(“application/json,text/plain”, txt, ParameterType.RequestBody)
Dim r = client.Execute(request)
Response.Write(r.Content)`HERE is the C# Rest from Postman’s (working version)
`var client = new RestClient(“https://staging3.reekooz.com/wp-json/wc/v3/orders/227175”);
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader(“Content-Type”, “application/json”);
request.AddHeader(“Authorization”, “Basic correct string”);
request.AddHeader(“Content-Type”, “text/plain”);
request.AddParameter(“application/json,text/plain”, “{\n \”status\”: \”preparing\”\n}”, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);`The connection takes place and my response has the entire order, but the status is not updated to preparing. (Yes, preparing is added as a custom status, and as I said, this works in Postman)
- The topic ‘Order Update PUT API in VB.net not working’ is closed to new replies.