• Resolved yonahs

    (@yonahs)


    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 .NET

    Here 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)

    • This topic was modified 4 years, 7 months ago by yonahs.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    Hi @yonahs,

    Seeing as the operation is working as expected in Postman, you’ll most likely want to debug your VB.Net code to see what’s not working properly.

    You’ll probably get the best assistance on a VB.Net specific forum or message board as this doesn’t seem to be a WooCommerce specific issue as shown by your ability to get this working in Postman.

    Thread Starter yonahs

    (@yonahs)

    @luminus

    Thanks, I have done that too…

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @yonahs,

    Great to hear that. I’m going to mark this thread as resolved now as this isn’t a .NET forum so you’re unlikely to get further interaction.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Order Update PUT API in VB.net not working’ is closed to new replies.