Skip to content

Amplify API PUT/POST only sends "application/json" content-type #2647

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

Closed
1 task done
tylerjroach opened this issue Dec 7, 2023 · 2 comments
Closed
1 task done

Amplify API PUT/POST only sends "application/json" content-type #2647

tylerjroach opened this issue Dec 7, 2023 · 2 comments
Assignees
Labels
api bug Something isn't working closing soon This issue will be closed in 7 days unless further comments are made. REST API Related to the API (REST) category/plugins

Comments

@tylerjroach
Copy link
Member

Before opening, please confirm:

Language and Async Model

Not applicable

Amplify Categories

REST API

Gradle script dependencies

All Versions

Environment information

All Versions

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

Customers are free to pass their own Content-Type header into POST/PUT requests. This provided header is part of this sigv4 signature.

However this line results in application/json being the actual Content-Type sent to the server:

requestBody = RequestBody.create(bodyBytes, JSON_MEDIA_TYPE);

This will result in response failing due to signature mismatch.

Customers should be able to provide their own Content-Type. The fix should grab content-type from customer headers if one exists, otherwise fallback to application/json then sign. The RequestBody.create method should then pass the proper content type instead of the hardcoded JSON_MEDIA_TYPE.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@tylerjroach tylerjroach added REST API Related to the API (REST) category/plugins api bug Something isn't working labels Dec 7, 2023
@tylerjroach
Copy link
Member Author

This fix for this issue has been released in Amplify 2.14.10 🎉

@tylerjroach tylerjroach added the closing soon This issue will be closed in 7 days unless further comments are made. label Feb 8, 2024
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api bug Something isn't working closing soon This issue will be closed in 7 days unless further comments are made. REST API Related to the API (REST) category/plugins
Projects
None yet
Development

No branches or pull requests

1 participant