Rodrigo,
If the json format does not fil the EO, I think you will have to create it
manually and set the values from the requestNode().
ERXRestRequestNode is keyValueCoding compliant, you can do something like this:
requestNode = requestNode();
newEO = EOUtilities.createAndInsertInstance(editingContext(), "EntityName");
newEO.setXyz(requestNode.valueForKey("xyz"));
...
Samuel
> Le 9 juin 2016 à 23:37, Rodrigo de Sousa <[email protected]> a écrit :
>
> Hello Samuel,
>
> Thanks for your answer.
>
> I forgot to mention, but in my case I got this problem to create the object.
>
> The method that I got the error is this:
> ERXRouteController.create(String entityName, ERXKeyFilter filter)
>
> I know that I can use the filter to use with primitive attributes but it not
> work with Object.
>
> Do you have any idea in my case to create an object and don't change my old
> API?
>
> Thanks again,
> Rodrigo.
>
> 2016-06-08 20:06 GMT-04:00 Samuel Pelletier <[email protected]
> <mailto:[email protected]>>:
> Hi,
>
> I think your only solution is to create a custom NSDictionary with the
> required key and return it like this:
>
> NSMutableDictionary<String, Object> result = new NSMutableDictionary<String,
> Object>();
> result.setObjectForKey(someObject.federalDocument(), "federalDocument");
> result.setObjectForKey(someObject.customer(), "customer");
>
> return response(result, ERXKeyFilter.filterWithAllRecursive());
>
> This will returns all attributes and relationships of customer, adjust the
> filter if required.
>
> Samuel
>
>
>> Le 8 juin 2016 à 16:22, Rodrigo de Sousa <[email protected]
>> <mailto:[email protected]>> a écrit :
>>
>> Hello,
>>
>> I am using the ERRest in my project and I am having a problem. I changed
>> some attributes to a new relationship, but I want to discover if there is a
>> way to not change my old API request.
>>
>> For example:
>>
>> Old request:
>> {
>> "customer": {
>> "email": "[email protected] <mailto:[email protected]>",
>> "name": "Rodrigo de Sousa",
>> "phone": "11 1234-5678"
>> },
>> "federalDocument":"123123123"
>> }
>>
>> Now, I have a new relationship called Sale Detail that have a customer.
>>
>> New request:
>> {
>> "saleDetail": {
>> "customer": {
>> "email": "[email protected] <mailto:[email protected]>",
>> "name": "Rodrigo de Sousa",
>> "phone": "11 1234-5678"
>> },
>> "federalDocument":"123123123"
>> }
>> }
>>
>> I know that I can use the ERXKeyFilter.filterWithAllRecursive() and add in
>> the map like in the example below. It works well with primitive attributes,
>> but I can use some like this with an Object (in my case, the Customer)? Is
>> possible to continue using the old request and not break my API?
>>
>> Example:
>> filter.addMap("saleDetail.federalDocument", "federalDocument");
>>
>> With this example, I can use the federalDocument in the old way. I tested
>> here and it works.
>>
>> I can use some like in the example below?
>>
>> Example:
>> filter.addMap("saleDetail.customer", "customer");
>>
>> When I tried to use this, this exception was thrown:
>>
>> java.lang.IllegalArgumentException: There is no to-one relationship named
>> 'saleDetail.customer' on 'CommercialInvoice'.
>> at
>> er.rest.ERXRestRequestNode.updateObjectWithFilter(ERXRestRequestNode.java:1296)
>> at
>> er.rest.ERXRestRequestNode.createObjectWithFilter(ERXRestRequestNode.java:863)
>> at er.rest.routes.ERXRouteController.create(ERXRouteController.java:670)
>> at er.rest.routes.ERXRouteController.create(ERXRouteController.java:638)
>>
>> Thanks for any help!
>> Rodrigo.
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected]
>> <mailto:[email protected]>)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>> <https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com>
>>
>> This email sent to [email protected] <mailto:[email protected]>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]