HTTP POST redirecting instead of POSTing

Excursionist
22 2 1

Hi there

 

I am using an HTTP POST to add orders to Shopify using the API.  However, although this seems to work OK on a server with an older OS, the server I am using (Windows Server 2016 Standard) does not behave correctly.  Instead of POSTing the JSON data it is redirecting to the admin area of the shop.  Any ideas from anyone?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
296 32 59

Hey Peter,

 

It sounds like you may be including header cookies in your request, which is causing Shopify to block the request and redirect you to the admin.

 

What tool are you using to make the API call? I would double check to make sure you have all header cookies removed using a tool such as Postman, and then trying to make the API call again.

0 Likes
Excursionist
22 2 1

Hi.  Thanks so much for replying.  It seems unlikely that I am setting cookies, but I am not that familiar with this object.  This is the code I am using that is redirecting instead of POSTing, where the variable jsondata contains the JSON that is working with this code on older OS servers, and indeed did work with this code on this server about 3 months ago, so I am thinking it is a result of some Windows Update that has happened recently?

Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP") 
xmlhttp.Open "POST", "https://<apiusername>:<apipassword>@<shopname>.myshopify.com/admin/api/2019-04/orders.json", false, "<apiusername>", "<apipassword>"
xmlhttp.setRequestHeader "Content-Type", "application/json; charset=utf-8"
xmlhttp.setRequestHeader "Content-Length", Len(jsondata)
xmlhttp.Send jsondata 
Set xmlhttp = nothing
0 Likes