question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "Payload is set but no content-type header specified" when calling play()

See original GitHub issue

Describe the bug

I’m seeing an issue where when I call play() without any parameters, I get an exception with the error message “Payload is set but no content-type header specified”.

To Reproduce This reproduces every time I call play(). I am using React Native and reproducing this on an Android phone. Interestingly, I’m only seeing this for play() but not pause(). I also have another project that uses React (instead of React Native) and runs in desktop Chrome and am not observing this issue.

Additional context Below is the full response returned by Spotify:

{
    "UNSENT": 0,
    "OPENED": 1,
    "HEADERS_RECEIVED": 2,
    "LOADING": 3,
    "DONE": 4,
    "readyState": 4,
    "status": 0,
    "timeout": 0,
    "withCredentials": true,
    "upload": {},
    "_aborted": false,
    "_hasError": true,
    "_method": "PUT",
    "_response": "Payload is set but no content-type header specified",
    "_url": "https://api.spotify.com/v1/me/player/play",
    "_timedOut": false,
    "_trackingName": "unknown",
    "_incrementalEvents": false,
    "_requestId": null,
    "_headers": {
        "authorization": "Bearer BQD1k6iCo2ITQdQTzX6VfGmYwGdeK7rAoAufwi4YDUzJI2EFnENC-q_Z1x2QljnT0TooLJbHUQMn_vKYv5zwig_4ZRWBdboZpFRZ8FuocHBcLMEp-ib-7Ia1r3c8Q87H3Jwu30Hr8ZUr2fOlnx77_w9c2bLIQAAcQW8"
    },
    "_responseType": "",
    "_sent": true,
    "_lowerCaseResponseHeaders": {},
    "_subscriptions": []
}

After some trial and error, I discovered that if I remove the line postData: postData from request.Data in play(), things will work fine: image

Despite the workaround, I’m still interested in getting to the bottom of this, and hopefully fix it in a non-hacky way if possible.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JMPerezcommented, Nov 2, 2020

Hi @quentin-sommer, you’re right! I have just published 1.5.1

0reactions
quentin-sommercommented, Nov 2, 2020

Thanks a lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - "Payload is set and no content-type header ...
You may try to set the content-type explicitly before calling your .send() method e.g. request.setRequestHeader('Content-Type', 'text/html').
Read more >
payload is set but no content-type header specified #184
While running Sentry on Android for the first time I got an error saying I needed to set content-type for header. "payload is...
Read more >
X-Content-Type-Options - HTTP - MDN Web Docs - Mozilla
The X-Content-Type-Options response HTTP header is a marker used by the server to indicate that the MIME types advertised in the ...
Read more >
RFC 7231: Hypertext Transfer Protocol (HTTP/1.1)
If a Content-Type header field is not present, the recipient MAY either ... Response messages with an error status code usually contain a...
Read more >
Best practices for REST API design - Stack Overflow Blog
Set the Content-Type header in the response to application/json; charset=utf-8 without any changes. The method above applies to most other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found