Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests with bodies must have content-type of application/json #6

Open
xatxay opened this issue Feb 19, 2024 · 0 comments
Open

Requests with bodies must have content-type of application/json #6

xatxay opened this issue Feb 19, 2024 · 0 comments

Comments

@xatxay
Copy link

xatxay commented Feb 19, 2024

When i used multipart to send a tweet i'd get 400 error saying {\"errors\":[{\"message\":\"Requests with bodies must have content-type of application/json.\"}],\"title\":\"Invalid Request\",\"detail\":\"One or more parameters to your request was invalid.\",\"type\":\"https://api.twitter.com/2/problems/invalid-request\"}

// this gave me the 400
let content = multipart::Form::new()
    .text("status", "Hello, Twitter!");
    
.multipart(content)

A work around i did was

let tweet_data = json!({"text": "hello"}).to_string();

.header("Content-Type", "application/json")
        .body(tweet_data)

just posting here in case someone run into this same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant