How to specify HTTP response status code in AML R Web Service

Lauri Lehman 136 Reputation points

Is there any way to return a custom HTTP status code from R Web Service in Azure ML?

All the examples of entry scripts in documentation return the response body from the scoring function. In Python Web Service, it is possible to return a HTTP response object with a custom status code. However, R's httr library does not seem to have any function to create response objects directly (only via HTTP method objects such as POST, which call a given URL).

I would like to implement a custom exception handling scheme in R Web Service. Is there any way to return a custom HTTP code from the entry script?

EDIT: Found this idea on the feedback forum, which suggests that the option is not available in Python Web Service either:

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,618 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Lauri Lehman 136 Reputation points

    I found that it is possible to return "502 Replica failed" by raising an exception in the entry script. However, it would still be nice to be able to return custom status codes.

    0 comments No comments

  2. Bozhong Lin 1 Reputation point

    This sample shows how to return custom StatusCode (returns 200 or 500):