TypeError [ERR_INVALID_ARG_TYPE] webhook when the request type is application/json
Problem
Issue Summary I was using Twilio Studio setting up an appointment reminder, for the confirmation widget, I setup the request and content as below: <img width="345" alt="image" src="https://user-images.githubusercontent.com/499870/95715064-f17bc880-0cb4-11eb-9e80-51ba415e32e5.png"> and my server code is simply like below: [code block] When the confirmation callback hit my server, Twilio webhook throws: [code block] I checked the twilio source code, mainly caused by this function: [code block] obviously if the request type is application/json, express will parse the request.body to an object right away, which causes the issue. By changing the request type to "Form URL Encoded" fixes my issue: <img width="291" alt="image" src="https://user-images.githubusercontent.com/499870/95715350-6b13b680-0cb5-11eb-924a-0cf9e315c0a4.png"> Steps to Reproduce 1. Set up Twilio webhook middleware in your express server 2. Set up a confirmation callback request to your server with request type to application/json Technical details: twilio-node version: twilio@3.49.4 node version: 10.x
Error Output
Error [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: TypeError [ERR_INVALID_ARG_TYPE] webhook when the request type is application/json
Hello @neekey, Thank you for taking the time to report this! I was able to reproduce this error locally. This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog. With best regards, Elmer
Trust Score
3 verifications
- 1
Thank you for taking the time to report this!
Thank you for taking the time to report this!
- 2
I was able to reproduce this error locally. This issue has been added to our int
I was able to reproduce this error locally. This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
Validation
Resolved in twilio/twilio-node GitHub issue #617. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep