eddof13

Problem with AGSJSONRequestOperation

Discussion created by eddof13 on Aug 23, 2011
Latest reply on Sep 22, 2011 by eddof13
Hi,

Thought I'd point out what may be a problem with AGSJSONRequestOperation (or at least something that should be mentioned in the documentation). Anyway, following the directions on the page http://help.arcgis.com/en/arcgismobile/10.0/apis/iOS/2.0/concepts/00pw/00pw0000004w000000.htm:

I found a quirk with the json that it is capable of returning. It appears that they key "error" is not accepted.

{"error": "The login credentials are not valid."}


returns an error in the api:

2011-08-23 13:02:50.896 LNOSitRep[6324:ec03] -[NSCFString allKeys]: unrecognized selector sent to instance 0x6292700

2011-08-23 13:02:50.899 LNOSitRep[6324:ec03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString allKeys]: unrecognized selector sent to instance 0x6292700'

*** Call stack at first throw:

(

0   CoreFoundation                      0x01b855a9 __exceptionPreprocess + 185

1   libobjc.A.dylib                     0x01cd9313 objc_exception_throw + 44

2   CoreFoundation                      0x01b870bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187

3   CoreFoundation                      0x01af6966 ___forwarding___ + 966

4   CoreFoundation                      0x01af6522 _CF_forwarding_prep_0 + 50

5   LNOSitRep                           0x0001fc3a -[AGSJSONRequestOperation processResultData:] + 593

6   LNOSitRep                           0x000215ee -[AGSRequestOperation requestOperationDidFinishLoading:] + 716

7   LNOSitRep                           0x000212d4 -[AGSRequestOperation connectionDidFinishLoading:] + 79

8   Foundation                          0x01581112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108

9   Foundation                          0x0158106b _NSURLConnectionDidFinishLoading + 133

10  CFNetwork                           0x0216c48e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220

11  CFNetwork                           0x022376e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293

12  CFNetwork                           0x022379cf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043

13  CFNetwork                           0x02162c80 _ZN19URLConnectionClient13processEventsEv + 100

14  CFNetwork                           0x02162acf _ZN17MultiplexerSource7performEv + 251

15  CoreFoundation                      0x01b668ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15

16  CoreFoundation                      0x01ac488b __CFRunLoopDoSources0 + 571

17  CoreFoundation                      0x01ac3d86 __CFRunLoopRun + 470

18  CoreFoundation                      0x01ac3840 CFRunLoopRunSpecific + 208

19  CoreFoundation                      0x01ac3761 CFRunLoopRunInMode + 97

20  GraphicsServices                    0x025f41c4 GSEventRunModal + 217

21  GraphicsServices                    0x025f4289 GSEventRun + 115

22  UIKit                               0x00de5c93 UIApplicationMain + 1160

23  LNOSitRep                           0x00002629 main + 121

24  LNOSitRep                           0x000025a5 start + 53

)

terminate called throwing an exception


I was able to fix it by using the following as my result instead
{"errorMessage": "The login credentials are not valid."}


I just thought that I should mention it, because it seems that using the { "error": "message" } convention may be obvious (and used in other esri REST services). If this is actually a problem on my end please tell me, I'd like to know.

Thanks

Outcomes