…eviously setted content-type in constructBodyParams method
When sending web conversions API to twitter using the post method of the library Twitter returns a 500 http error.
According to this twitter post to avoid the error the header 'content-type' : 'application/json;charset=UTF-8' must be used.
Even if the headers 'content-type' is setted in the post() method args field, the 'content-type' is then overwritten by the constructBodyParams() method. The solution could be using the forceBodyMode :'json' in the post() method but in doing so the library converts the entire body to a string by using JSON.stringify() and the "stringed" body is not valid and the Twitter API rejects it.
The solution is to accept the forced content-type from the postargs field and not overwrite it.
…eviously setted content-type in constructBodyParams method
When sending web conversions API to twitter using the
post
method of the library Twitter returns a 500 http error.According to this twitter post to avoid the error the header 'content-type' : 'application/json;charset=UTF-8' must be used.
Even if the headers 'content-type' is setted in the
post()
methodargs
field, the 'content-type' is then overwritten by theconstructBodyParams()
method. The solution could be using theforceBodyMode :'json'
in thepost()
method but in doing so the library converts the entire body to a string by usingJSON.stringify()
and the "stringed" body is not valid and the Twitter API rejects it.The solution is to accept the forced content-type from the
post
args
field and not overwrite it.