Connectivity help through API C# RestSharp with API Key / API Secret Key

BMSUser
New Member
4 0 0

Hi,
I am creating a app to upload new products using API using JSON/C#. I am using RestSharp and NewtonSoft.Json

I have a partner login through which I have created a APP bmswave.myshopify.com
and generated key/password etc.

The store bmswave.myshopify.com has several products and few orders which I have created.

I have correctly entered API key and APi Secret key in following line

 

  var client = new RestClient("https://bmswave.myshopify.com/admin");
            client.Authenticator = new HttpBasicAuthenticator("xxxx", "1234");

            var request = new RestRequest("/products/", Method.GET);

I am using same URL, which I used to generate the key. https://bmswave.myshopify.com/admin

I am not able to login through the API.  I am not seeing any products nor request object has any valid values.

Could you please help?

Thanks!

Replies 6 (6)
csam
Shopify Staff
154 24 25

Hi @BMSUser 

What is the full URL that you are making the request too? It should be in the format storename.myshopify.com/admin/api/2021-01/products.json You can read more about the Product endpoint here: https://shopify.dev/api/admin/rest/reference/products/product#endpoints-2021-01

What is being returned from Shopify when you make your request? If you could please provide the x-request-id header value, I can try having a look in our logs if needed. 

 

CS | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

BMSUser
New Member
4 0 0

Hi,

I changed my code a bit and request and response code 

 var client = new RestClient("https://bmswave.myshopify.com");

client.Authenticator = new HttpBasicAuthenticator("**", "**");

string resource = "/admin/api/2021-07/products.json";

var requestres = new RestRequest(resource, Method.GET);
requestres.AddUrlSegment("status", "open");

requestres.AddHeader("header", "Content-Type: application/json");
IRestResponse response = client.Execute(requestres);

 

Response Content is : "{\"errors\":\"[API] Invalid API key or access token (unrecognized login or wrong password)\"}"

ResponseURI is {https://bmswave.myshopify.com/admin/api/2021-07/products.json}

Headers 

{X-Request-ID=e9787c97-606d-46c6-a282-8bf07fead5ec}

 

Thanks!

csam
Shopify Staff
154 24 25

Thanks for that! I took a look and it looks like a normal permissions error. If you're sure you have the correct credentials for that shop, are they perhaps in the wrong order? I'm not able to see the API key or password on my end so I can't tell. 

CS | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

BMSUser
New Member
4 0 0

Hi ,

I changed the order of key and PWD just to confirm but no luck. 

When you say permissions error, do I need to set any permissions in the store? like ADMIN API PERMISSIONS

I cannot find any link to do it.

Also in my partner login, I created an app, where I generated API keys, APP URL is https://bmswave.myshopify.com/admin

When I use this link in my browser

https://key:pwd@bmswave.myshopify.com/admin/api/2021-07/products.json

I get list of products successfully..

{"products":[{"id":3602996527184,"title":"ALEX 3\/4 SLV PRINTED BLOUSE BLK\/RED-L","body_html":"\u003cp\u003eALEX 3\/4 SLV PRINTED BLOUSE BLK\/RED-....etc 

Thanks for your help!

 

csam
Shopify Staff
154 24 25

Are you using the password or the secret key field? You should be using the API key and password fields: 
21-09-78upc-y74at

 

If you're already logged in to the admin, you don't need to use authorize with the key and password - you will automatically have access. Can you try using your browser in incognito mode with the same credentials?

CS | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

BMSUser
New Member
4 0 0

Hi,

I pasted the link below with API key and Secret key in Incognito mode and I was able to see the products json reply.

https://xx:key@bmswave.myshopify.com/admin/api/2021-07/products.json

How do I access API Admin screen where I see Api key and password? I see API Key and Secret key not password.

I got this credentials generated from Apps menu under https://partners.shopify.com

Not sure if I am generating credential from correct place.

Thanks for your help!