c# - Woocommerce REST API V2: The remote server returned an error: (401) Unauthorized. Status ProtocolError -


i want update order status through woocommerce rest api v2 in windows service project. got sample c# code download orders link

consuming woocommerce rest api c#

its working fine downloading orders local server. want update order/add order note.

i tried

    public string updateorder()     {         //return makeapicall_mine("orders/17", new dictionary<string, string>() { { "order", "{\"status\":\"completed\"}" } });//         return makeapicall_mine("orders/17");     }     private string makeapicall_mine(string endpoint, dictionary<string, string> parameters = null, string method = "put")     {         if (parameters == null)         {             parameters = new dictionary<string, string>();         }         parameters["oauth_consumer_key"] = this.consumerkey;         parameters["oauth_timestamp"] =             datetime.utcnow.subtract(new datetime(1970, 1, 1, 0, 0, 0)).totalseconds.tostring();         parameters["oauth_timestamp"] = parameters["oauth_timestamp"].substring(0,             parameters["oauth_timestamp"].indexof("."));         parameters["oauth_nonce"] = hash(parameters["oauth_timestamp"]);         parameters["oauth_signature_method"] = "hmac-sha256";         parameters["oauth_signature"] = generatesignature(parameters, method, endpoint);         webclient wc = new webclient();         stringbuilder sb = new stringbuilder();          foreach (var pair in parameters)         {             sb.appendformat("&{0}={1}", httputility.urlencode(pair.key), httputility.urlencode(pair.value));         }         var url = this.apiurl + endpoint + "?" + sb.tostring().substring(1).replace("%5b", "%5b").replace("%5d", "%5d");         //var result = wc.downloadstring(url);         wc.uploadstring(url, "{\"order\":{\"status\":\"completed\"}}");          //return result;         return "";      } 

but getting error the remote server returned error: (401) unauthorized

my woocommerce user permissions:read/write.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -