Hello,
I am in the process of building an API for Ebay interfaces. I need to send some client credentials in the "body":
grant_type=client_credentials&scope=api.ebay.com/.../api_scope
I use the class System.Net.HttpWebRequest.
However, I don't know how to post something in the body. Can anyone here possibly help me how I could simply implement it?
I have attached a code snippet:
private str sExecuteRequest(str _sSubURL, str _sRESTMethod, System.Net.WebHeaderCollection _oHeader) { str sResponse; System.Net.HttpWebRequest oRequest; System.Net.HttpWebResponse oResponse; System.Net. // System.Net.NetworkCredential oCredentials; System.IO.StreamReader oReader; System.IO.Stream oDataStream; CLRObject oClrObj; ; oClrObj = System.Net.WebRequest::Create(_sSubURL); oRequest = oClrObj; //Create Header oRequest.set_Method(_sRESTMethod); oRequest.set_Headers(_oHeader); oRequest.set_ContentType(#HeaderContentType); oRequest.set_Accept(#HeaderContentAccept); // "grant_type", "client_credentials&scope=https://api.ebay.com/oauth/api_scope" oResponse = oRequest.GetResponse(); oDataStream = oResponse.GetResponseStream(); oReader = new System.IO.StreamReader(oDataStream); sResponse = oReader.ReadToEnd(); oReader.Close(); oDataStream.Close(); oResponse.Close(); return sResponse; }
I get the error message above the tool Fiddler:
{"error":"unsupported_grant_type","error_description":"grant type in request is not supported by the authorization server"}
Thank you in advance.