Search code examples
iosrestswift2swift-playgroundhttp-request

ios swift 2.1 - unable to send Patch request with body


I'm trying to write a http rest client for my webservice and i need to send some PATCH requestes with data in the body.

I'm using the JUST library for sending requests ( https://github.com/JustHTTP/Just )

My express application just doesn't see the request. Here's some code (i'm testing in playground, and everything went fine with other kind of requests like put, post...)

headers = ["accept":"application/json","content-type":"application/json","authorization":"key"] //key is ok

var data = ["id":3, "quantity":6] 

var r =   Just.patch("http://api.marketcloud.it/v0/carts/1233", headers:headers, data:data) //1233 is a cart Id

print(r)
print(r.json)

The method Just.patch returns an HTTPResult Object. this says 'OPTIONS http://api.marketcloud.it/v0/carts/13234 200'

Also this object should contain a json, but it's 'nil'.

On the server-side, my express applications doesn't receive the request (it just logs an 'OPTION', but nothing else).

Could this be a playground-related problem? Or a just-related one?

Thanks for any suggestion


Solution

  • I managed to contact the library's author via twitter and he fixed the bug and answered me in less than 24h!

    Here's the new release of the library.

    https://github.com/JustHTTP/Just/releases