Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

How to allow user to GET using a multipart key

When using a GET request on a collection of items that use multipart keys, I get a url for an item that looks something like api/endpoint/101*1. However, when I use that url in a GET request, I get an 400 error from Abyss Web Server. My guess is that Abyss is blocking the asterisk character. Is there a way to tell Abyss to allow this to be passed to the SRP HTTP Framework? If not, how can I use endpoints that are linked to tables with multipart keys?

Thanks

Comments

  • I'm not sure why Abyss is returning a 400 error nor am I sure how to configure it to accept the asterisk. I did a quick test and confirmed your results. You may want to investigate Abyss' technical support for answers.

    Must your end point include the asterisk? Personally I think it looks a bit odd. I would have suggested a dash or even a slash. In your API you can swap it for an asterisk so you can safely read the database record. Remember, the URL is an abstraction of the resource on your server. It doesn't have to mirror the database and probably shouldn't in most cases.
  • I use "~" in place of an asterisk for my multipart keys. It seems to work and only required a minor change in http_resource_services to perform the swap. I'm using IIS though, not Abyss.

    Eg: api/timecards/4252~weglenor~17797~28800~57600
  • Mark's suggestion is fine if you expect all URLs that pass in multi-part Key IDs will always use the same alternate delimiter. Personally I would leave HTTP_Resource_Services alone so it can better survive an upgrade and I would just do the swap in the API end point service.
  • Too late. :P
  • >>just do the swap in the API end point service.
    But it would not get the key because of the intial problem reported.
    The HTTP_Resource_Services would need to be changed to change the hyperlink that is created with the */~ substitution.
  • ...or do you mean change it in the API end point service which is the one returning the json by changing it in the json.!
  • All I meant was in order to take and end point like this:

    /salesman/123-2

    And still use HTTP_Resource_Services "as is", then in the GET method service handler he would just need to convert the "-" to "*" and then pass that in to get the record.

    The self referencing URL that is automatically produced in the HAL+JSON response would include the '*'. In that case, your suggestion would be acceptable.
Sign In or Register to comment.