Backendless Support
 
Answered

Multiple HTTP Methods for one API Method/URL

Hi all,

at the moment I'm trying to develop a small API with codeless to store and load custom data in backendless. In our design and concept of the API we wanted to have one URL/Method per datatype.

So simplified lets say I want to store a picture out of my software in backendless and load it later. For this we wanted to have a URL like: domain.tdl/api/<version>/picture/binary. At the moment in codeless I don't find a way to have multiple HTTP methods (GET, POST, PUT, DELETE) per URL/API method.

Am I missing something? Or will be a way to do so? Otherwise we poorly have to change that in our concept, as I like the fact to have one URL and not multiple URLs like: /picture/getbinary, /picture/putbinary, /picture/deletebinary

Cheers,

Jonas

Leave a Comment

Comments (2)

photo
1

Hi Jonas

When you create/update your Codeless Method

- you have to define UNIQUE method name in your API Service

- but you can specify the same route with different Rest Method (GET, POST, PUT, DELETE)

ff2927af5ce79862b4f64cf530ec9b37

so, in your case you need to create 4 Methods in your Service

1) [ name: "GetPicture", method: "GET", route: "/picture/binary" ]

2) [ name: "CreatePicture", method: "POST", route: "/picture/binary" ]

3) [ name: "UpdatePicture", method: "PUT", route: "/picture/binary" ]

4) [ name: "DeletePicture", method: "DELETE", route: "/picture/binary" ]

12261c4e65333ae6fef465f7bccd7ee9

and you can call the method by this routes:

GET: https://{DOMAIN}/{APP ID}/{API KEY}/services/{SERVICE NAME}/picture/binary

POST: https://{DOMAIN}/{APP ID}/{API KEY}/services/{SERVICE NAME}/picture/binary

PUT: https://{DOMAIN}/{APP ID}/{API KEY}/services/{SERVICE NAME}/picture/binary

DELETE: https://{DOMAIN}/{APP ID}/{API KEY}/services/{SERVICE NAME}/picture/binary

4246f8139173905bdf1285366e31fc6b

Regards, Vlad

photo
1

Hi Vlad,

thats exactly what I need. Thank you very much.

I thought so far that the route has to be unique as well. But now it's clear.

Best Regards,

Jonas