See method in endpoints

I am setting up some endpoints for our customers to use. They want to both send data into Appfarm and get them out again.

I would like to set up two endpoints, one GET and one PATCH, for certain objects, so that the url is equal but the methods have slightly different logic, as one would expect. I see two ways I could do that in Appfarm, but I’m getting errors on both:

Either I could set up one endpoint that is accessible with several methods. The problem here is that it looks like I cannot set up any logic on which method the end user uses? I would expect to see fx method under fx Built-in Service Variable or Context Params, but I see no such thing. Is there any possibility for me to see which method is used?


The other way I imagine to solve this issue is to set up two endpoints, one for the get and one for the patch, with the same url. I see that I get a warning in create if I set the two endpoint to accept the same method, which makes sense. No warning when I set them to be different. However, I get this error when running the GET endpoint:

    "error": {
        "name": "TypeError",
        "message": "Cannot redefine property: headers",
        "statusCode": 500

Is this an Appfarm error? Or something I have set up wrong? The only header I have created is a token to get access to the right company, but that is equal for the two endpoints, the only difference is the method.


Hi,

The method you mentioned last; using two endpoints, is the best practice to do it.

If the setup is the same for GET and PATCH, and it is working for the PATCH endpoint, it might be an error in the process action you are running for the GET request.

TypeErrors can occur from functions, so if you are using that, it might be the right place to debug.

If the problem persists, please send some more details about the setup.