Webhooks Send Blank Body

Webhooks Send Blank Body

CR3
Shopify Partner
4 0 0

I created a variety of webhooks via the API (they exist and are posting back to my server as well for the proper event triggers).

The issue however is that the body of the POST that its the server is blank.  Only thing I'm getting out of the request is some HTTP Header info, which includes (below).

Any ideas what I might be doing wrong?

Thanks,

Jason

Array
(
    [Content-type] => application/json
    [Content-Type] => application/json
    [X-Shopify-Topic] => carts/create
    [X-Shopify-Shop-Domain] => abc123.myshopify.com
    [Accept-Encoding] => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
    [Accept] => */*
    [User-Agent] => Ruby
    [Connection] => close
    [Host] => dev.xxxxxxxxx.com
    [Content-Length] => 331
)

 

Replies 5 (5)

Chris_Saunders
Shopify Staff
591 0 53

That's pretty odd. Is the content 331 spaces or something?

Chris | 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

CR3
Shopify Partner
4 0 0

Figured it out... for future reference:

$rawData = file_get_contents('php://input');
$data = json_decode($rawData);

 

pardeepprotolab
Shopify Partner
1 0 0

HI, I am having the same issue. I am using nodejs and expressjd and in the req.body i get nothing. What did you do to solve this problem?

KarlOffenberger
Shopify Partner
1873 184 902

Hi @pardeepprotolab

 

Can you be a little more specific? If your content length isn't 0, then it's probably somewhere on your side of the code - have you made sure the content type is correct, have validated the HMAC and are accessing the body correctly - usually by wiring up body-parser via

 

app.use(express.bodyParser())

Have you tested your webhook handler in isolation?

 

Best wishes!

Chris_Saunders
Shopify Staff
591 0 53

Awesome!

Chris | 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