Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

POST and PUT not working #1

Open
maciejnowak22 opened this issue Apr 18, 2013 · 5 comments
Open

POST and PUT not working #1

maciejnowak22 opened this issue Apr 18, 2013 · 5 comments

Comments

@maciejnowak22
Copy link

when trying to insert data into db using following request:

POST /testowa1 HTTP/1.1 Host: localhost:8888 User-Agent: CocoaRestClient/11 CFNetwork/596.3.3 Darwin/12.3.0 (x86_64) (****************) Content-Length: 33 Accept: application/json Content-Type: application/json Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: keep-alive `{ "id":4,"column" : "POST"}`

i'm getting response:

HTTP/1.1 200 OK Date: Thu, 18 Apr 2013 00:19:26 GMT Server: Apache X-Powered-By: PHP/5.4.10 Content-Length: 45 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: application/json `{"error":{"message":"No Content","code":204}}`

i'm using MAMP apache, and mysql. Tried on table with auto_incement index and one inserted manually, PUT and POST seems to not working (with the same err).

GET and DELETE works great

f.e.
using GET for http://localhost:8888/table/3 causes following response:

HTTP/1.1 200 OK
Date: Thu, 18 Apr 2013 00:30:22 GMT
Server: Apache
X-Powered-By: PHP/5.4.10
Content-Length: 28
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json

{"id":"3","column":"asdfg"}

@alixaxel
Copy link
Collaborator

@maciejnowak22

I'm pretty sure you have to send the body data URL-encoded or multipart - application/json won't get picked up.

@alixaxel
Copy link
Collaborator

alixaxel commented Jun 2, 2013

@maciejnowak22 I've implemented support for JSON and zlib'ed payloads in ArrestDB if you still need it.

@roestigraben
Copy link

Hi there,
I have exactly the same problem (see also my bug submitted recently).So, how did you resolve the issue then?
The problem seems to be that the wrong body data coding parameter has been used. One should not use URL-encoded.
MAybe at the same time, would you know how to can enforce this parametere with the AngularJS $resource methods?
many thnaks for the support
Roestigraben

@maciejnowak22
Copy link
Author

@roestigraben ,
as @alixaxel said i had to send body data url-encoded instead of json.

so my body looks sth like this:

"key=value&anotherKey=anoutherValue"

where keys are column names in database.

@alixaxel,

thnx a lot for your effort! solutions with url-encoded was enough for me. If i will meet in future similar task ArrestDB will be considered as first.

@roestigraben
Copy link

@maciejnowak22
thanks, yes, works now for me when I test it with a jQuery testing done like
jQuery.ajax({
url: 'http://localhost:8888/angular18/api/allIP',
type: "POST"
processData: "false",

    data:'name=mynewIP&provider=myNewProvider&technology=28nm',
    success: function(data) {
      console.log(data);
    },
    error: function(data) {
      console.log(data);
    }
  });

Now I just need to code my AngularJS $resource parameters such that it does the same as with jQuery (or with another REST console).
Also thnaks for your really quick response. Very appreciated

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

No branches or pull requests

3 participants