Fullfillment Rest API redirected to login page

New Member
9 0 0

Hi,

 

I am trying to fulfill an order using Rest API, below is the payload.

 

POST: /admin/api/2019-04/orders/#{order_id}/fulfillments.json

{
"fulfillment": {
"location_id": 421426,
"tracking_number": "1Z47434103",
"tracking_urls": [
"http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber1=1Z47434103&TypeOfInquiryNumber=T&Accept..."
],
"notify_customer": true
}
}

 

Response: 

<html>
<body>
You are being
<a href="https://XXXXXX.myshopify.com/admin/auth/login">redirected</a>.
</body>
</html>

 

could successfully fulfill couple of orders using similar request payloads. Passing all valid values for Order_id, Location_id, tracking# and tracking URL.

Please help.

 

Thanks,

 

 

0 Likes
Highlighted
Shopify Expert
11 0 3

@Lakshmana 

If using C# this might help, however it's the same issue. A cookie is created sometimes silently in the framework you are using to send the request from - so ensure you explicitly get rid of it:

 

We had the same issue yesterday. It's related to Cross-Site Request Forgery (CSRF).

Looks like any requests which have a cookie are being rejected - in C# we had to explicitly disable cookies as follows:

 

var httpClient = new HttpClient(new HttpClientHandler
{
     UseCookies = false
});

 

This turns off cookies - surprisingly this worked - and did confirm that the Http Client was enabling cookies as all our requests worked instantly from this point onwards.

 

We found this which pointed us in the right direction.

Referenced Shopify update: https://community.shopify.com/c/API-Announcements/Shopify-now-prevents-HTTP-Basic-Auth-POST-requests...

 

 

META - Shopify Experts
www.meta.co.uk
0 Likes