Authentication error (401 Unauthorized)

Highlighted
New Member
9 0 0

Hi,

I want to get orders from API. when i use API url in Code then give Authentication error 401 ( Unauthorized).

Please share full API URL with all requirement parameters so that I can access all orders details.

 

we follow this patterns as

https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json

 

 

0 Likes
Explorer
63 13 17

Hi, @Aroma_Magic. Have you created private app?)

Thanks for reading, don’t forget to like and subscribe!
Wrong outro - Click Like and Accept as Solution if it was helpful and help other to find the answer ?
0 Likes
New Member
9 0 0

Yes

i have already created private app. and use API Key and password in API Url.

0 Likes
Explorer
63 13 17

Great, can you visit private app configuration page and copy "Example URL" to address bar. Do you get successful response?

Thanks for reading, don’t forget to like and subscribe!
Wrong outro - Click Like and Accept as Solution if it was helpful and help other to find the answer ?
0 Likes
New Member
9 0 0

Hi, @Yurіі. Thanks for reply. 

Please share screen short or link of private app configuration page with Example URL so that i can show. 

0 Likes
Explorer
63 13 17

I mean visit or create your private app:

- create - ${yourstorename}.myshopify.com/admin/apps/private

- visit ${yourstorename}/admin/apps/private/${app_id}

And check access through "Example URL" for your private app :)

 

Screenshot from July 17, 2019 11_20 AM.png

Thanks for reading, don’t forget to like and subscribe!
Wrong outro - Click Like and Accept as Solution if it was helpful and help other to find the answer ?
0 Likes
New Member
9 0 0

Hi, @Yurіі. Thanks for reply. 

 

Sir, When I check Example URL using postman then data is shown but when i use same example URL in my Code then give Authentication Error.

"The remote server returned an error: (401) Unauthorized."

 

 

 

0 Likes
Explorer
63 13 17

Cool. Then it's related to invocation in the code. Can you share code snippet which invokes error?

Thanks for reading, don’t forget to like and subscribe!
Wrong outro - Click Like and Accept as Solution if it was helpful and help other to find the answer ?
0 Likes
New Member
9 0 0

Hi,

 

Please find the Code

try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("Example-Url"));
request.Method = "GET";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
var ApiStatus = reader.ReadToEnd();
string json = @ApiStatus;
json = json.Replace("\"", "'");
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}

 

0 Likes