-
Notifications
You must be signed in to change notification settings - Fork 332
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 returns HTML not JSON #94
Comments
Xcode 10.0 |
Hi @broadwaycodez, Making a POST request to that URL with Could you post the list of request headers that you are sending? Possibly adding a |
Thanks for responding! Here is my code. I have the "application/json" header, and I get a status code of 200, which is good. But I can't find a way to parse 'data' to get the generated URL. `let parameters = ["password[payload]": "myPassword", "password[expire_after_days]": "3", "password[expire_after_views]": "10"] var request = URLRequest(url: "https://pwpush.com/p.json") if let httpBody = try JSONSerialization.data(withJSONObject: parameters, options: []) {
}` |
Hrm all looks good at first glance. It doesn't appear to be a pwpush bug but I'll try running your code and a few more test scenarios. Need to take care of a few other things first but I'll post back here with results soon. |
Thanks so much for your help on this! I just wanted to check in. Were you able to get a different response using my code? |
I haven't been able to run your code as I don't have a swift env setup to test on but I just had a thought... Try adding one additional header that indicates what the response should be: So you would add something like the following:
This will hopefully force the response to be json. |
That's great 😀. If no objections I'll add that swift example to the wiki.
Peter Giacomo Lombardo
…On Mon, Oct 8, 2018, 5:08 PM broadwaycodez ***@***.***> wrote:
That was the magic bullet! I also had to structure my parameters a little
differently than the JS example on the wiki. For anyone interested, this
was the final construction of my POST request:
[image: screen shot 2018-10-08 at 11 04 44 am]
<https://user-images.githubusercontent.com/43583254/46617323-77734080-caea-11e8-8858-ec3f23f4d930.png>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#94 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYHfEH9RTB-aSrBel4gaNQMadA3WvvHks5ui2p2gaJpZM4XBSmJ>
.
|
None at all! If you want, I can also post my code for decoding the JSON response into a parseable Swift object. |
I added a link to this issue as a swift example: https://github.com/pglombardo/PasswordPusher/wiki/Password-API If you want to post that additional code for Swift parsing, by all means, it would be appreciated. Thanks again @broadwaycodez |
I'm writing a simple mobile app to run internally which interacts with your password API, but when I send POST requests to the url (https://pwpush.com/p.json), the response I get back is the full HTML code for the front page of the website, not a JSON object that can be parsed. Has anyone else had this issue?
The text was updated successfully, but these errors were encountered: