{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"

Mohammed27
Tourist
6 2 0

Hi There,

I am trying to consume Orders API through C#.Net.

Below is my URL.

https://apikey:password@xxx.myshopify.com/admin/api/2020-07/orders.json/?status=any

When i am running this URL in Postman app is a receiving response(all orders).

But when i am trying to get the response from C# i am getting below error.

{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"

 

 

Below is the code  i am using 

 

string[] outPut;
var client = new RestClient(OrdersURL);
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Shopify-Access-Token", "mytoken");
var response = client.Execute(request);
Newtonsoft.Json.Linq.JObject orders = Newtonsoft.Json.Linq.JObject.Parse(response.Content.ToString());
IList<Newtonsoft.Json.Linq.JToken> results = orders["orders"].Children().ToList();

List<string> outputList = new List<string>();
for (int j = 0; j < results.Count; j++)
{
outputList.Add(results[j]["id"].ToString());
}

outPut = outputList.ToArray();
return outPut;

 

 

Please suggest what's wrong here or do in need to pass addational header along with request.

 

Thanks,

0 Likes