Arrest-MySQL icon indicating copy to clipboard operation
Arrest-MySQL copied to clipboard

POST and PUT not working

Open maciejnowak22 opened this issue 12 years ago • 5 comments

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"}

maciejnowak22 avatar Apr 18 '13 00:04 maciejnowak22

@maciejnowak22

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

alixaxel avatar May 20 '13 23:05 alixaxel

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

alixaxel avatar Jun 02 '13 13:06 alixaxel

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

roestigraben avatar Jul 19 '13 14:07 roestigraben

@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.

maciejnowak22 avatar Jul 19 '13 15:07 maciejnowak22

@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

roestigraben avatar Jul 19 '13 19:07 roestigraben