expected String to be a Hash

Solved
mikg
Tourist
4 1 0

Hi Everyone,

 

I have a problem on creating Fulfillment or creating a test transaction.

I followed the documentation in REST API but still got and error "expected String to be a Hash".

I used Postman to having this error but when I updating an inventory I haven't encountered this error.

I also tried to search regarding this error but no luck.

 

Thank you in advance,

Accepted Solutions (2)

Accepted Solutions
Ryan
Shopify Staff
Shopify Staff
497 42 117

This is an accepted solution.

Check out our using Postman guide.  Content-Type should be application/json, and the target URL should just be:

 

 

https://{{api_key}}:{{api_password}}@{{store_name}}.myshopify.com/admin/api/2019-07/orders/{{order_number}}/fulfillments.json

You wouldn't include the parameters in the URL.  You also cannot include cookies.  Your parameters look fine and should just be included as a raw body in postman.

 

Ryan | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

mikg
Tourist
4 1 0

This is an accepted solution.

Hi Ryan,

 

I change my settings in Postman and encountered a new error message "not found". And figure out the error, I just remove the "s" in "line_items". In documentation of creating fulfillment it was "line_items" not "line_item".

 

Thank you for guiding,

Jimmy

View solution in original post

Replies 7 (7)
Ryan
Shopify Staff
Shopify Staff
497 42 117

Hi @mikg 

 

In order to assist you I'll need a bit more information.  Can you provide me the X-Request-ID header that is returned from the Shopify API with the error message?  Also helpful is if you could include the exact request you are making.

 

Regards.

Ryan | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

mikg
Tourist
4 1 0

Hi Ryan,

 

My Parameters :

{
    "fulfillment":{
       "location_id":"12345",
       "tracking_number":"test",
       "tracking_company":"test_compant",
       "line_items":[
            {"id":"123"}
        ]
    }
}

My Header Request in Postman :

POST /admin/api/2019-07/orders/#{id}/fulfillments.json?fulfillment=%7B%22location_id%22%3A%2212345%22%2C%22tracking_number%22%3A%22test%22%2C%22tracking_company%22%3A%22test_compant%22%2C%22line_items%22%3A%7B%22id%22%3A%22123%22%7D%7D

HTTP/1.1
Host: api_key_and_password@store_name.myshopify.com
Content-Type: application/x-www-form-urlencoded
User-Agent: PostmanRuntime/7.17.1
Accept: */*
Cache-Control: no-cache
Postman-Token: token,token
Host: store_name.myshopify.com
Accept-Encoding: gzip, deflate
Authorization: Basic OGZmYTk3MjMyODVkMzIwZWNiMzc0ZmQ1NDFkNjEzODI6Y2U1Mzk1ODBiMGYxMDI1Y2NlODA4Y2JmNGEwNDg1ZWY=
Cookie: __cfduid=d28d25200ab7196fabaffd33c945a571c1568939996
Content-Length: 0
Connection: keep-alive
cache-control: no-cache

Shopify Error Message:

{
    "errors": {
        "fulfillment": "expected String to be a Hash"
    }
}

I hope it can helps.

 

Thank you,

Ryan
Shopify Staff
Shopify Staff
497 42 117

This is an accepted solution.

Check out our using Postman guide.  Content-Type should be application/json, and the target URL should just be:

 

 

https://{{api_key}}:{{api_password}}@{{store_name}}.myshopify.com/admin/api/2019-07/orders/{{order_number}}/fulfillments.json

You wouldn't include the parameters in the URL.  You also cannot include cookies.  Your parameters look fine and should just be included as a raw body in postman.

 

Ryan | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

mikg
Tourist
4 1 0

This is an accepted solution.

Hi Ryan,

 

I change my settings in Postman and encountered a new error message "not found". And figure out the error, I just remove the "s" in "line_items". In documentation of creating fulfillment it was "line_items" not "line_item".

 

Thank you for guiding,

Jimmy

fs-akjha
New Member
1 0 0

Everyone , Getting below error while accessing the webhook:- 
My Code:- 


@main.route('/webhook',methods=['POST'])
def create_webhook():
    acces_token='tokenhere'
    params={"webhook":
    {
      "topic": "orders/create",
      "format": "json",
      "fields" :["id", "note"]
    }
}
    r=requests.post(webhook_url,data=params,headers={'X-Shopify-Access-Token':acces_token})
    print(r.json())
    # result=r.json()
    return "200"


Giving Content-Type as application/json
Getting below error:- 
{'errors': {'webhook': 'expected String to be a Hash'}}

Please help me sort it out
sparkdeath324
New Member
1 0 1

If you're using python requests, just use the following 

 
response_data = requests.put(urljson=payload)
 
instead of using "data" I simple replaced it with json
dexterpengji
New Member
1 0 0

Thank you! saved me a lot of time