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

Update http.md to reflect code in CapacitorHttpUrlConnection #175

Closed
wants to merge 1 commit into from

Conversation

michaelhonan
Copy link

Was having trouble getting my post requests to send a JSON body, even though my code matched the documentation's demo.

Found out by looking at the @capacitor/core Java code that if ContentType isn't set, it'll just return and not set the body of the request.

https://github.com/ionic-team/capacitor/blob/895f86a81ee76b23ed33fa088ee3c9feec1ecd7f/android/capacitor/src/main/java/com/getcapacitor/plugin/util/CapacitorHttpUrlConnection.java#LL180C46-L180C46

Let me know if you'd prefer to handle something like this a little different. I would've preferred CapacitorHttpUrlConnection.setRequestBody() to throw an Exception, but I figured I'd just try to document the gotcha.

@vercel
Copy link

vercel bot commented May 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
capacitor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2023 5:10am

@michaelhonan michaelhonan changed the title Update http.md to reflect code in Update http.md to reflect code in CapacitorHttpUrlConnection May 3, 2023
@jcesarmobile
Copy link
Member

this is a bug on the plugin, it should work even if no content type header is present, at least having a default content type
ionic-team/capacitor#7245

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

Successfully merging this pull request may close these issues.

2 participants