What am I doing wrong, i'm trying to pass a parameter to a exposed REST service

Hello.


I'm new in this outsystems world, I've done the Web Developer Learning Path and now I was developing a REST service for the Bookings Assignment. The problem is, I've created a server logic which receives a Id parameter of type Room Identifier, mandatory. Then I created a REST method DeleteRoom with a Id parameter with the same type as the server logic, Room Identifier, mandatory. And a Response output.


When I go to the Inmsonia to request the method, I pass the following inputs:

DELETE request ON Bookings_rest/rest/Rooms/Room

Body type JSON: 

{
      "Id": 1


When I execute, Outsystem's response give me the following error:


{
  "Errors": [
    "Failed to parse. 'RoomIdentifier' compatible data type is required for parameter 'Id'."
  ],
  "StatusCode": 400
}


What's happening?

Hi Lucas,

I don't know how you've created the REST API method, but by default you pass the parameters in the URL, so calling it would look something like

https://server/espacename/restapiname/restapimethod?Id=1

Carlos Ribeiro da Fonseca wrote:

Hi Lucas,

I don't know how you've created the REST API method, but by default you pass the parameters in the URL, so calling it would look something like

https://server/espacename/restapiname/restapimethod?Id=1


Yes... actually, I'm a Computer Science student in the first year and don't know much the standard pratices yet, I made this try before, passing in URL with the DELETE request and it works as normally, but when I change it to pass in the body as a JSON, it gives me the error. I'm wondering if it is something that i'm mistaking of or it's OutSystem's itself.

Ah!

I believe you need to change a number of things to get that working.

first you have to change the HTTP Method to PUT or POST, like this one:


then change the Receive In property to Body:


Carlos Ribeiro da Fonseca wrote:

Ah!

I believe you need to change a number of things to get that working.

first you have to change the HTTP Method to PUT or POST, like this one:


then change the Receive In property to Body:



If I just create an Structure with only one attribute Id, with type "Room Indentifier" and use that Structure on API Id request parameter it works. if it's outside the Struct it doesn't work. Maybe it has to do with OutSystem's internals?