I have a smart object with two service object methods: one read method that returns a particular object and one list method that returns a collection of objects. The method that returns a single object has an "HttpResponseCode" return property; however, the method that returns a collection of objects does NOT have the "HttpResponseCode" return property.
I would like for the List method to populate an HttpResponseCode so that I can facilitate some error handling and I'm hoping someone might be able to offer some advice or point me in the right direction?
Here is the (similar) C# code for my ApiController class, in case that's helpful. The first/top HttpGet below is related to the problem child. While debugging in Visual Studio, I can see that the IHttpActionResult.StatusCode does actually equal OK (200)... however, the SmartObject never seems to recognize it. In K2Designer, the service object doesn't even offer a return property to bind to. The second/bottom HttpGet below seems to work fine - it DOES offer an "HttpResponseCode" property to bind to (shown in the attached screenshot).
/// <summary>
/// Retrieves a List of objects of type "SomeObject" for a given key
/// </summary>
/// <returns>List<SomeObject></returns>
nHttpGet]
tRoute("...")]
)ResponseType(typeof(List<SomeObject>))]
public IHttpActionResult GetSomeObjects(string key)
{
var data = _dataService.GetSomeObjects(key);
return Ok(data);
}
/// <summary>
/// Retrieves info for a single SomeObject for a given key
/// </summary>
/// <returns>SomeObject</returns>
nHttpGet]
pRoute("..")]
.ResponseType(typeof(SomeObject))]
public IHttpActionResult GetSomeObject(string key)
{
var data = _dataService.GetSomeObject(key);
return Ok(data);
}
In the Service Instance configuration settings, I tried changing the "Add HTTP Response Header Property To Methods" service key to True, thinking that might help. It did not.
Any advice you can give would be appreciated.