POST request result is an HTML page instead of JSON

Solved
Highlighted
Excursionist
11 1 0

Hi Shopify community,

I got a problem when I try to "POST" anything on my shopify store. Is there any option I need to activate ?

I try to "POST" a "products.json" or a "inventory_levels/set.json" and the result is the same: an HTML page with a "Continue" link ????

 

I work with 2 customers. On one of the custommers store my request are all working, but on the other it doesn't work.

It's not me that create accounts and store. But, I gave my account all the access in the "private apps manager", but the result is the same.

 

Here is a "products.json" request ID : X-Request-Id=c6b0ff01-b875-4575-86fa-b538081bd98e

Here is a "inventory_levels/set.json" request ID : X-Request-Id=92571ca7-77f4-4a2a-a2fa-b5b23a2a96ee

 

Is there anyone who can help me please ?

 

Thanks for the help.

0 Likes
Highlighted
Excursionist
11 1 0

Some more details... I'm a delphi programmers. All of my request "POST" works on 1 of my 2 shop.

On the one that is not working, the result is : 401 unauthorised ?

 

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
516 100 97

You need to remove the cookies you are sending with the post request. There are a lot of forum posts that describe this process in detail. Once you do that, you should be able to send a POST no problem. 

 
 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Highlighted
Excursionist
11 1 0

Thanks Vix!

I already saw a lot of post talking about those cookies.

But, I use the same request with the same tool on two different shopify and I got this error only on 1 of my shopify ? The request works on the other.

I'm not very good with cookies... Do I need to remove cookies from somewhere ? I use a tool from Embarcadero "REST Debugguer" to run my request.

Is there anything I can do ?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
516 100 97

The other issue could be due to authentication, so make sure to check your API key / access token / auth setup. I'm not familiar with Embarcadero unfortunately, but you should be able to track down how to check + remove if you are sending cookies with the request. If you have no luck, maybe try with Postman by following our tutorial and debug from there first: https://shopify.dev/tutorials/debug-apps-with-postman-for-mac-os

 
 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Highlighted
Excursionist
11 1 0

Thanks vix for your quick answer.

I take a look at Postman and test it. My request works with Postman and when I get back to my Embarcadero tool it doesn't work.

In my tool (REST Debugger), there is no place where I can add/remove cookies. I try running the request from my "custom application", where I already run GET/POST request.

The result is a 401 error, like my request was unauthorized ? Is here anything that I can do ?

 

Thanks for your time and your help

0 Likes
Highlighted
Excursionist
11 1 0

I just did another test in my "custom app".

1. I run a request on the store where it already works, so everything is ok

2. I run the same request (with the same components) on the other store, so I change my authentification... and the response "404: Not Found" in JSON is {"error": Not Found}

My request is a "inventory_levels/set.json" and I verify my "inventory_item_id" and "location_id" and they are good.

 

Thanks for your help

0 Likes
Highlighted
Shopify Partner
667 47 134

If you can trace the API request/response traffic using Fiddler, Wireshark, etc. then you can see if your Embarcadero client is indeed sending along client-side cookies or some funky header values. Looking a Wiki page (http://docwiki.embarcadero.com/RADStudio/Sydney/en/REST_Debugger_Tool) there appear to be some options you can employ with your client to enforce things. If your API request succeeds using Postman then there definitely appears to be an issue with Embarcadero client you are using. 

0 Likes
Highlighted
Excursionist
11 1 0

Thanks Greg for the help

I run the "POST request - inventory_levels/set.json", here is the error that I got now : {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}

Just to be sure, I run a "GET request - locations.json" with the same API key/password and it works.

I look back at my "Admin API permissions" and I have access to everything.

 

I don't understand what is my problem. Do you think that I should trace the API request/response traffic using Fiddler, wireshark or another program ? Because I never use those tools.

I'm new with Shopify API.

Thank you very much for your help.

0 Likes
Highlighted
Shopify Partner
667 47 134

I would definitely suggest employing Fiddler, Wireshark, or some other tracing app for seeing what's being sent. Nine times out of ten if a GET request works, while a POST request throws this type of error, it's due to client-side cookies of some sort being sent. Especially if you've verified you have access to this scope... 

0 Likes