api: update stock / add transaction to order

New Member
3 0 0

I know these are two different issues, but since the api responds with the same exact (odd) response on both occasions, I'm posting them as one issue:

 

1. updating stock

This api call

POST https://prefix.myshopify.com/admin/api/2019-07/inventory_levels/adjust.json
{
	"inventory_item_id": 18463715262554,
	"location_id": 18262458458,
	"available_adjustment": 4
}

results in this html?? response:

<html>
 
<body>
	<noscript>
		<a
			href="https://app.shopify.com/services/login/identity?destination_uuid=91475eec-6581-4290-a106-7d84bf95711c&amp;return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3Dprefix%26state%3DPeM8yVtTX8xiLWh-Jej2cwF-oKIF9T8Y7vxfoOO4L00qK_yP75OPSk57Rr6ib1xgQAPeD7c86bSkd9xzlik9enFv8MaOdjvaYm4Keg-_iHsQ6gSTJgprBrtXUNhBLZ7rwWfwzVl4VROUMgCaNOXNchX6mdGxCcaewnsfdtNgLYbnWDEkqz4qPu1HbqNTbJkDQwiLZ07hPF72LG_Qug_8G7S-qwzxk7ho4TOpxPWZylQ%253D&amp;ui_locales=en&amp;upgradeable=true&amp;ux=shop">Continue</a>
	</noscript>
 
	<script type="text/javascript">
		window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=91475eec-6581-4290-a106-7d84bf95711c\u0026return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3Dprefix%26state%3DPeM8yVtTX8xiLWh-Jej2cwF-oKIF9T8Y7vxfoOO4L00qK_yP75OPSk57Rr6ib1xgQAPeD7c86bSkd9xzlik9enFv8MaOdjvaYm4Keg-_iHsQ6gSTJgprBrtXUNhBLZ7rwWfwzVl4VROUMgCaNOXNchX6mdGxCcaewnsfdtNgLYbnWDEkqz4qPu1HbqNTbJkDQwiLZ07hPF72LG_Qug_8G7S-qwzxk7ho4TOpxPWZylQ%253D\u0026ui_locales=en\u0026upgradeable=true\u0026ux=shop";
	</script>
</body>
 
</html>

2. add transaction to order

This api call

POST https://prefix.myshopify.com/admin/api/2019-07/orders/1543469989978/transactions.json
{
    "transaction": {
        "currency": "EUR",
        "kind": "sale",
        "amount": "34.85"
    }
}

results in the same response 

<html>
<body>
  <noscript>
    <a
      href="https://app.shopify.com/services/login/identity?destination_uuid=91475eec-6581-4290-a106-7d84bf95711c&amp;return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3Dprefix%26state%3DRsisMOjwD3kwaQS1ltUSjpAoEUb9IGsfDVJp-nAI18clAC7ifyQv3nGfOwNN18fHDE_ZGNfgfpxJOWu3iToe9hQxeLzNUUies9MqEMDqtbY4dpjvbKLsm2Nan0auHb3JmEUUrLa94AaSiiYRafb7veqaU6CkJA6R6nd5Si4XN89dEm3XCbv2rwF9QlwluTbtpLE8sdTuCRFmriTZYSg0Nr6CCnCeBZ-Fn2Cf1WnF__I%253D&amp;ui_locales=en&amp;upgradeable=true&amp;ux=shop">Continue</a>
  </noscript>
  <script type="text/javascript">
    window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=91475eec-6581-4290-a106-7d84bf95711c\u0026return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3Dprefix%26state%3DRsisMOjwD3kwaQS1ltUSjpAoEUb9IGsfDVJp-nAI18clAC7ifyQv3nGfOwNN18fHDE_ZGNfgfpxJOWu3iToe9hQxeLzNUUies9MqEMDqtbY4dpjvbKLsm2Nan0auHb3JmEUUrLa94AaSiiYRafb7veqaU6CkJA6R6nd5Si4XN89dEm3XCbv2rwF9QlwluTbtpLE8sdTuCRFmriTZYSg0Nr6CCnCeBZ-Fn2Cf1WnF__I%253D\u0026ui_locales=en\u0026upgradeable=true\u0026ux=shop";
  </script>
</body>
</html>

Which is very odd considering that this is supposed to be a json api and this is obviously html.

 

Since the returned html prompts for a login, my first thought was that this is an authentication or authorisation issue, but sending along invalid credentials results in a proper json error response telling me that. 
Authorisation wise; all permissions that even remotely have something to do with orders and transactions and stock are on "read/write" for the used api key.

 

Any ideas?

0 Likes
Community Manager
Community Manager
619 45 77

Hi @OLerch,

 

How are you making these calls? The response you receive looks like the response you would receive when you are making a POST request with cookies. I've seen this behaviour occur unintentionally when using some HTTP clients such as Postman.

 

If you can share the X-Request-Id response header value, I can take a look in our logs for you.

 

Thanks!

0 Likes
Highlighted
New Member
3 0 0

Hi @Busfox 

 

thanks for the tip, that was indeed the problem.  Clearing all cookies from Postman resolved the issue.

0 Likes