Closed antonantonovich closed 2 months ago
Sorry, just saw this.
Can you give me relevant parts of your metadata xml (or the whole file preferrably) and generated source please?
<Action Name="GetPreferenceValue" IsBound="false">
<Parameter Name="prefIntName" Type="Edm.String" Nullable="false">
<Annotation Term="Core.Description">
<String>Internal name of the Preference</String>
</Annotation>
</Parameter>
<Parameter Name="containerRef" Type="Edm.String">
<Annotation Term="Core.Description">
<String>Container Object ID</String>
</Annotation>
</Parameter>
<ReturnType Type="Edm.String"/>
<Annotation Term="Core.Description">
<String>Get Preference value for input preference and container.If container is not passed,session
user specific preference is fetched.
</String>
</Annotation>
</Action>
Generate client code:
@Action(name = "GetPreferenceValue")
@JsonIgnore
public ActionRequestReturningNonCollection<String> getPreferenceValue(String prefIntName, String containerRef) {
Preconditions.checkNotNull(prefIntName, "prefIntName cannot be null");
Map<String, TypedObject> _parameters = ParameterMap
.put("prefIntName", "Edm.String", prefIntName)
.put("containerRef", "Edm.String", containerRef)
.build();
return new ActionRequestReturningNonCollection<String>(this.contextPath.addActionOrFunctionSegment("GetPreferenceValue"), String.class, _parameters);
}
That action reply with the value and HTTP 200 status from the server side but we have an error on client side because client expects 201 status.
for example, that action works correctly
<Action Name="QueryDesigns" IsBound="false">
<Parameter Name="object" Type="DesignDisplayInput" Nullable="false"/>
<ReturnType Type="Elements" Nullable="false"/>
<Annotation Term="Core.Description">
<String>Query endpoint used by design interface</String>
</Annotation>
</Action>
@Action(name = "QueryDesigns")
@JsonIgnore
public ActionRequestReturningNonCollectionUnwrapped<Elements> queryDesigns(DesignDisplayInput object) {
Preconditions.checkNotNull(object, "object cannot be null");
Map<String, TypedObject> _parameters = ParameterMap
.put("object", "DesignDisplayInput", object)
.build();
return new ActionRequestReturningNonCollectionUnwrapped<Elements>(this.contextPath.addActionOrFunctionSegment("QueryDesigns"), Elements.class, _parameters);
}
ActionRequestReturningNonCollectionUnwrapped response allows to have HTTP 200 status but ActionRequestReturningNonCollection do not
Gotcha, I see that such a post is assumed to be a create action which is not correct. I'll widen it to accept all 2XX codes.
0.2.2 is on Maven Central now with the fix. Please give it a try, thanks for the report.
closing, reopen as you wish
Hello David,
We have an issue trying to call Action that returns Edm.String and HTTP 200 status. The error is "The api of post GetPreferenceValue gives exception of expectedresponse 201"
I checked that when action returns not collection Edm type -- it uses ActionRequestReturningNonCollection and that request accepts only 201 status.
When we have Action that returns custom type, client uses ActionRequestReturningNonCollectionUnwrapped request and that request allows to have any success status.