Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
I am issuing a request via Postman

"https://APIKEY:PASSWORD@myexampledomain.myshopify.com/api/2021-04/custom_collections.json"

and I get a true response:

JavaScript
{
    "custom_collections": [
        {
            "id": 264277491901,
            "handle": "baran-kategori",
            "updated_at": "2021-04-08T18:05:03+03:00",
            "published_at": "2021-04-05T16:40:08+03:00",
            "sort_order": "best-selling",
            "template_suffix": "",
            "published_scope": "web",
            "title": "Baran Kategori",
            "body_html": ""
            
        },
        {
            "id": 264276377789,
            "handle": "category1",
            "updated_at": "2021-04-06T14:49:26+03:00",
            "published_at": "2021-04-05T16:12:36+03:00",
            "sort_order": "best-selling",
            "template_suffix": "",
            "published_scope": "web",
            "title": "Category1",
            "body_html": ""
            
        },
        {
            "id": 264362623165,
            "handle": "nike",
            "updated_at": "2021-04-08T18:05:03+03:00",
            "published_at": "2021-04-06T16:17:49+03:00",
            "sort_order": "best-selling",
            "template_suffix": "",
            "published_scope": "web",
            "title": "Nike",
            "body_html": ""
            
        }
    ]
}


when attempting to do the same GET through httpclient or restsharp, I am getting a 401 unauthorized.

{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers: { Date: Thu, 08 Apr 2021 16:12:33 GMT Transfer-Encoding: chunked Connection: keep-alive X-Sorting-Hat-PodId: 188 X-Sorting-Hat-ShopId: 56072536253 Referrer-Policy: origin-when-cross-origin X-Frame-Options: DENY X-ShopId: 56072536253 X-ShardId: 188 WWW-Authenticate: Basic Realm="Shopify API Authentication" Content-Type: application/json; charset=utf-8 Content-Length: 89 }}

What I have tried:

..............................................
Posted
Updated 8-Apr-21 6:48am
Comments
Richard Deeming 9-Apr-21 4:11am    
You are sending different headers in your C# code than your Postman request.

Since we can't see either request, or the relevant parts of your C# code, we can't tell you which header is causing the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900