0

This is kinda a follow up question from this previous one:

https://stackoverflow.com/questions/16804632/ios-how-to-add-integer-and-null-into-json-post-using-nsmutablerequest-and-catch

Basically when I try to see what type of body the NSMutableRequest is sending I'm getting this:

json request is <7b224632 4964223a 2235222c 22496422 3a223122 2c225375 626d6973 73696f6e 54797065 4964223a 2230222c 22463149 64223a22 33222c22 4576656e 74496422 3a223522 2c224272 61636b65 74496422 3a223322 2c224631 53636f72 65223a22 30222c22 57696e6e 65724964 223a302c 22463241 6476223a 2230222c 224e6f74 6573223a 22686570 7070222c 2254696d 65223a22 4e554c4c 222c2246 3253636f 7265223a 2230222c 22463141 6476223a 2230222c 2257696e 42794964 223a2230 227d>

It's basically utf encoded. But that's the only type of object sethttpbody is accepting. I'm sending it to a MVC .Net Web Api. So I'm not sure if I need to do some type of conversion to recognize the json data sent from the iphone.

Also, whenever I would return an HttpResponseMessage from my web api, this part

NSLog(@"response is status code %ld with value %@", (long)[response statusCode], [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]);

will only display this message

2013-05-30 23:30:53.882 Sammabiatch Admin[1156:c07] response is status code 400 with value bad request

I was wondering how to get any other parts of the message as in .Net there are multiple properties for HttpResonseMessage. eg. StatusCode, ReasonPhrase, Content, Headers, RequestMessage and Version.

Any help is much appreciated. Thanks!!!

Community
  • 1
  • 1
gdubs
  • 2,724
  • 9
  • 55
  • 102
  • Can you see what the data looks like when it reaches the server? Can you print it out there? – Marcel May 31 '13 at 09:16
  • Hm. See that's a good question. Cuz that's one of my main issue, whenever there's something wrong with the data you passed it will return a HTTPREsponseMessage which basically will only have a StatusNumber passed back (eg. 400 404 500 etc), with which NSMutableRequest (or NSJSonSerialization, idk w/c one executes it) can't seem to read, it'll return only the code and translate what the code means (eg. 400, bad request). Maybe I should just change the return type to a json data? (using MVC 4.0 web api). Also, tried sending the encoded via fiddler (using local) to it and the ViewModel will – gdubs May 31 '13 at 11:26
  • ViewModel of the api will be null if my content-type is "application/json" if on the other hand it's "application/x-www-form-urlencoded" it would recognize the viewmodel but will have 0 and/or null on all the properties. I hope that made sense for MVC peeps. – gdubs May 31 '13 at 11:28
  • Use a proxy or network debugger for better info, check this question http://stackoverflow.com/questions/16808072/how-to-detect-urls-requested-by-iphone-iphone-simulator/16808420#16808420 – Marcel May 31 '13 at 12:15
  • That's awesome, I didn't know such a thing exists. I'll try it out – gdubs May 31 '13 at 12:47
  • So I've been working on this for almost a day now but still couldn't make it work. I'm getting some errors ... http://stackoverflow.com/questions/16889888/socketrocket-after-trying-to-install-socketrocket-so-that-i-can-make-ponydebugge . Any chance you can take a peek and see if you know anything about it? THanks! – gdubs Jun 03 '13 at 04:09

0 Answers0