Re: ERRest error messages as JSON instead of XML?
Re: ERRest error messages as JSON instead of XML?
- Subject: Re: ERRest error messages as JSON instead of XML?
- From: Mike Schrag <email@hidden>
- Date: Thu, 05 May 2011 17:37:26 -0400
just override errorResponse and do whatever you want … it's not returning "xml" it's returning a json string that contains html in it. you can make it do whatever, though.
On May 5, 2011, at 5:32 PM, Andrew Kinnie wrote:
> OK well, the issue appears to still be if you attempt to create something using rest, and do not provide all the required attributes, you get something like "Please provide a <b>Udid</b>."
>
> if you run it on the command line, and presumably in the console of the app itself. It does not stop on a break point I placed on the first line of the action method to do the create, it does not stop on the break point I put in ERXRouteController's create() method. I don't get a stack trace in the console, nor any exceptions.
>
> I would like to convert this to json with the key errorString or something like that.
>
> This seems to be relatively low priority, as he has currently swallowed the error on the iOS side, but I would like to know where it's coming from so I can do something else with it.
>
> Presumably, I am just not aware of an easy way to get the stack trace, but I've got no idea.
>
> On May 5, 2011, at 4:38 PM, Mike Schrag wrote:
>
>> not sure why:
>>
>> public WOActionResults errorResponse(Throwable t, int status) {
>> String errorMessage = ERXLocalizer.defaultLocalizer().localizedStringForKey("ERXRest." + entityName() + ".errorMessage." + status);
>> if (errorMessage == null) {
>> errorMessage = ERXLocalizer.defaultLocalizer().localizedStringForKey("ERXRest.errorMessage." + status);
>> if (errorMessage == null) {
>> errorMessage = ERXExceptionUtilities.toParagraph(t, false);
>> }
>> }
>> String str = format().toString(errorMessage, null, null);
>> WOResponse response = stringResponse(str);
>> response.setStatus(status);
>> log.error("Request failed: " + request().uri(), t);
>> return response;
>> }
>>
>> it's calling format() to get the current format … breakpoint and/or stack dump what's generating that error.
>>
>> On May 5, 2011, at 4:34 PM, Andrew Kinnie wrote:
>>
>>> Greetings again,
>>>
>>> I am about to go live with my push server (using WO 5.4.3 and ERRest) to push out iOS push notification to iOS devices with our app we are submitting tonight, and it occurred to me I have one remaining issue with the ERRest implementation.
>>>
>>> Our iOS app consumes the data in json format (which is set as the default by the various controllers), but if there is an error of some nature in the returned response, the error comes back as XML and not json, causing a crash which the iOS app has to swallow and recover from. We'd much rather have the errors in json format so the same parser can effectively parse the response whether it succeeds or fails.
>>>
>>> Is there a way to get ERRest to return error messages as json instead of XML? I didn't see anything obvious, and now I am in a time crunch.
>>>
>>> Thanks in advance
>>>
>>> Andrew
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden