-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Post Request Never Executes, No Response Returned #41
Comments
Hi dalezak, I'm not able to reproduce your problem. Are you sure it's a plugin problem? Would you please try updating Ionic Native HTTP plugin to version 4.3.3? |
Hi, I have exactly the same problem. GET is working and POST no. Using http angular for the same post works. |
@silkimen I've upgraded to Is there anything that could prevent the request from being executed? Checked the server logs and doesn't look like it received the request. |
That's interesting. Can you please provide some more info?
|
Hi, |
Ok, I've created a ionic demo application with following components:
And this is my ionic setup:
I'm using following URL for testing purposes "http://httpbin.org/anything". I've tried setting data serializer to "json" and "urlencoded". I've tested it on iPhone X emulator with iOS 11.1 and on a real device iPhone 6s with iOS 11.0.3. I can't reproduce this problem. Maybe you could try debugging the plugin native code on your machine to find out whats wrong? |
Hi, So I have solved the issue by updating to 1.8.1 and before request setting the encoding to json or urlencode, depending on what I need. Also one thing that I saw and I did not find anywhere to be specified is that when using POST or PUT the param sent as payload must be passed as an object not as JSON stringfied or an already encoded url because the plugin will attempt to stringfied what you sent as param so will be doubled stringfied as json or url encoded. |
Thank you @AlexGoo, I'll test it out! Looks like
http://ionicframework.com/docs/native/http/#setDataSerializer |
Hmm @AlexGoo, I upgraded to Here's a sample of what my POST looks like:
I also removed the |
I think you also need to add the content type as header. Also did you intercepted the post to be sure that the body is ok formatted ? |
@AlexGoo looks like that did the trick! Setting Perhaps the
|
I believe this is now resolved, closing issue 👍 |
Why am I not able to get the values from response?
console.log(res.data); but console.log(res.data[0].USERNAME); |
I believe the resp.data is a string, so needs to be converted to JSON to access the response values.
let json = JSON.parse(resp.data);
console.log(json[0].USERNAME);
|
Thanks man! I was using |
No worries @madsongr, I ran into the same problem. If you wanted to access the
|
Hi, I ran into the same problem. POST is not sending data to the server. GET is working fine. Below is my code:- |
I posted this issue on Ionic Forum, but since it's likely a plugin issue thought I'd post it here as well.
I'm using Ionic Native HTTP plugin
4.3.2
with Ionic Angular3.7.1
on iOS 11 to POST data to a server. However the request never seems to get executed, it never gets back aHTTPResponse
or even an error.Doing a GET request works fine returns back a
HTTPResponse
, just POST that doesn't seem to work.I tried to POST to different servers to rule out whether it was a server side issue. Did something break in a recent update of the plugin?
The text was updated successfully, but these errors were encountered: