cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Odata Custom Rest Endpoint status code 201

xolomon
12-Amethyst

Odata Custom Rest Endpoint status code 201

Hi,

 

we have implemented a custom Odata Rest Endpoint. I want to return http status code 201 Created when an object is created and the status code 200 when an object is updated via post request. I couldn't achieve it by setting the boolean variable setCreated on the ActionResult that is returned. Does anybody have an idea?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
xolomon
12-Amethyst
(To:fivig)

Hi fivig,

thanks for your reply. I think it only works if you return the object as an entity. In our case I don't want to return a Windchill object but a custom response which contains string attributes. When you return a custom response in a way like below it doesn't work. 

ComplexValue complexValue = new ComplexValue();
complexValue.getValue()
.add(new Property("String", statusAttribute, ValueType.PRIMITIVE, statusAttributeValue));
EntityAttribute entityAttribute = new EntityAttribute(null, "Response",
PropertyValueType.COMPLEX, complexValue);
result.setReturnedObject(entityAttribute);

 

Cheers,

xolomon

 

View solution in original post

2 REPLIES 2
fivig
7-Bedrock
(To:xolomon)

Hi xolomon,

Looks strange, in WRS 2.1 should works fine. What is your version of WRS?

if actionResult.isCreated() then ActionProviderProcessor , return org.apache.olingo.commons.api.http.HttpStatusCodeHttpStatusCode.CREATED.getStatusCode()

xolomon
12-Amethyst
(To:fivig)

Hi fivig,

thanks for your reply. I think it only works if you return the object as an entity. In our case I don't want to return a Windchill object but a custom response which contains string attributes. When you return a custom response in a way like below it doesn't work. 

ComplexValue complexValue = new ComplexValue();
complexValue.getValue()
.add(new Property("String", statusAttribute, ValueType.PRIMITIVE, statusAttributeValue));
EntityAttribute entityAttribute = new EntityAttribute(null, "Response",
PropertyValueType.COMPLEX, complexValue);
result.setReturnedObject(entityAttribute);

 

Cheers,

xolomon

 

Top Tags