lukeredpath / LRResty

Yet another Objective-C REST client library, inspired by Ruby's restclient gem.
http://projects.lukeredpath.co.uk/resty/
461 stars 56 forks source link

submitting filters in url string #15

Closed ghost closed 13 years ago

ghost commented 13 years ago

Hi Luke. When I am submitting a url such as:

http://clklabvm11.aaa.bbbbbbbbbb.ca:8000/sap/opu/sdata/sap/ZCWMERCSVC/CustomerCollection?$filter=emailAddress eq 'test@example.com'&$sap-client=100&$format=xml

Resty throws:

2011-09-07 00:08:49.713 CWMercDemo[2974:b603] * Assertion failure in -[LRRestyHTTPClient requestForURL:method:payload:headers:requestDelegate:], /Users/admin/.jenkins/jobs/LRResty Nightly Builds/workspace/Classes/LRRestyHTTPClient.m:86 2011-09-07 00:08:49.715 CWMercDemo[2974:b603] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'LResty requires a valid HTTP(S) URL, received (null)'

I am guessing that this is due to the single-quotes in the url string? I tried to escape them with \ but the same exception is thrown... I am wondering if there is a way I can get url strings like this one work with Resty?

thanks,

steve

lukeredpath commented 13 years ago

Hi, what do you get back if you put the same string into NSURL +URLWithString? If that, as I suspect, is returning nil, then you will need to properly percent encode the URL.

Sent from my iPhone

On 7 Sep 2011, at 07:29, i00stevemreply@reply.github.com wrote:

Hi Luke. When I am submitting a url such as:

http://clklabvm11.aaa.bbbbbbbbbb.ca:8000/sap/opu/sdata/sap/ZCWMERCSVC/CustomerCollection?$filter=emailAddress eq 'test@example.com'&$sap-client=100&$format=xml

Resty throws:

2011-09-07 00:08:49.713 CWMercDemo[2974:b603] * Assertion failure in -[LRRestyHTTPClient requestForURL:method:payload:headers:requestDelegate:], /Users/admin/.jenkins/jobs/LRResty Nightly Builds/workspace/Classes/LRRestyHTTPClient.m:86 2011-09-07 00:08:49.715 CWMercDemo[2974:b603] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'LResty requires a valid HTTP(S) URL, received (null)'

I am guessing that this is due to the single-quotes in the url string? I tried to escape them with \ but the same exception is thrown...

thanks,

steve

Reply to this email directly or view it on GitHub: https://github.com/lukeredpath/LRResty/issues/15

ghost commented 13 years ago

Thanks Luke.

  1. +URLWithString did indeed return nil.
  2. Percent encoding the url fixes my problem!

Closing issue!

steve