Trying to add a Lead using v8 API getting "Method not allowed. Must be one of: GET"

Using Postman I have successfully retrieved my access_token and been able to get a list of existing leads, but each time I attempt a POST to add a lead I get the following response.

{
“message”: “Method not allowed. Must be one of: GET”
}

This makes no sense as to add it should be POST to add not GET.

Any Ideas?

Thanks.

Hi @JosephN, there are 2 solutions

1: Convert your request type to ‘GET’ in suitecrm,
2: Create a Custom Request on CRM side to allow post methods (if you are not a developer you can never do it, you need to engage any developer)

thanks

1: Convert your request type to ‘GET’ in suitecrm,

Converting to a GET doesn’t work. On top of that, it SHOULDN’T as this is a record add function that should use the POST method.

Create a Custom Request on CRM side to allow post methods (if you are not a developer you can never do it, you need to engage any developer)

I am a developer and could, however, shouldn’t the POST methods for the LEAD module record creation ALREADY be implemented and enabled as part of the default API?

I see lots of mentions of POST methods in the API Docs, so I guess that error message must be caused by something else, but I am afraid I have no idea what it might be, I never used the API myself… :frowning:

Hi @JosephN,

As per my knowledge, most of modules API methods in the CRM for V8 API are done by GET method…
But some are also PUT and POST. Any how, for your help.
Can you please check the ROUTE file in API folder, from there you can get an idea of WHICH method is done by GET and which one is by POST… Hope this will help you.

Api\V8\Config\routes.php

Thanks

$app->post mean POST is allowed
$app->get mean GET is allowed
$app->put mean PUT is allowed

In my routes.php everything looks correct for the module routes, there are 2 GETs, one for a list of the module records, one for a specific module record indicated by the id parameter, one POST for module record creation, one PATCH for module record update, and one DELETE for module record deletes.

Like I said before, with the Leads module I can GET the list of module records just fine and I can GET an individual module record just fine but I can’t get the POST working to create a module record…

I am following the developer documentation from the link below which specifically calls out POST for module record creation which even the example code below won’t let me create an Account module record. I just get the same response back.

Create a module record

POST {{suitecrm.url}}/V8/module

Example body:

{
  "data": {
    "type": "Accounts",
    "id": "86ee02b3-96d2-47b3-bd6d-9e1035daff3a",
    "attributes": {
      "name": "Test account"
    }
  }
}

Ok nevermind I have figured it out.

I was using the wrong URL for the POST, I was using the GET URL and they are different.

The get URLs use the following paths:

GET {{suitecrm.url}}/V8/module/{moduleName}
GET {{suitecrm.url}}/V8/module/{moduleName}/{id}

And I assumed for some reason my post path would be similar like this:

POST {{suitecrm.url}}/V8/module/{moduleName}

but it is NOT!

It is supposed to be:

POST {{suitecrm.url}}/V8/module

I was posing to

crm.server.com/V8/module/Lead

but should have instead been posting to

crm.server.com/V8/module

SIGH… This is what I get for rushing through something because I am trying to do TOO many other things at the same time, thanks for your help guys, I really appreciate it.

1 Like

Ok, You are welcome!