expected String to be a Hash

Tourist
4 0 1

Hello All,

I am using python and requests to push to the rest api. When I try to update any variant or product information, I get the "{u'errors': {u'product': u'expected String to be a Hash'}}" for the response. Has anyone come across this vague error and solve it?

Here is my json, I have simplified it down to just turning off the publishing boolean to eliminate any bleed over.

{
  "product": {
    "id": 632910392,
    "published": true
  }
}

 

1 Like
Shopify Staff (Retired)
Shopify Staff (Retired)
533 0 88

Hey Keith,

From the error message, it appears that you might be providing the product data as a string instead of a hash. You would want to use json.loads to convert string data to a hash. If you provide a code snippet, I may be able to help debug further.

 

You might also want to consider using the official shopify_python_api library.

1 Like
Shopify Partner
2 0 0

@Keith - came across the same issue as you utilizing Python with requests. Hope you already found the solution but either way, the fix was to have {"Content-Type": "application/json"} as part of the header request.

0 Likes
Shopify Partner
2 0 0

@Jamie - unfortunately shopify_python_api does not have support for script tags

0 Likes
Highlighted
Tourist
4 1 0

Hi Everyone,

 

I have the same error on creating Fulfillment. I followed the documentation in REST API but still got and error (expected String to be a Hash).

See documentation below:

https://community.shopify.com/c/Shopify-APIs-SDKs/expected-String-to-be-a-Hash/td-p/316028

 

0 Likes