API4.1 with Postman

Hello,

I am trying to play a little bit with the API4.1 from Postman but it seems it does not work. For sure there are some settings that i didn’t do.

This is the curl from Postman.

curl --location 'http://*.*.*.*/*******/service/v4_1/rest.php' \
--header 'Content-Type: application/json' \
--data '{
    "method": "login",
    "input_type": "JSON",
    "response_type": "JSON",
    "rest_data": {
        "user_auth": {
            "user_name": "*****",
            "password": "****************",
            "version": "1"
        },
        "application_name": "RestAPI"
    }
}

I have installed SuiteCRM 7.14.3 on an Ubuntu server.
I have hashed the password. i have even tried to make the api call from a php file.

All i received is the content of the rest.php file.

Best regards,

Mihai

You definitely have to use a POST-request.

This is what i am trying to use. Am i missing anything?

I’m sure there’s better way to do this, I’m not a postman expert, but here’s what I do:

Setup the login request:

Method: GET
image

{
    "method": "login",
    "input_type": "JSON",
    "response_type": "JSON",
    "rest_data": {
        "user_auth": {
            "user_name": "your-username",
            "password": "your-md5-password-hash",
            "version": "1"
        },
        "application_name": "RestTest",
        "name_value_list": []
    }
}

You’ll get returned your session ID:

image

Setup another request (to get a list of accounts for example)

Method: POST

image

{
    "method": "get_entry_list",
    "input_type": "JSON",
    "response_type": "JSON",
    "rest_data": {
        "session": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(the session id you got in step 1)",
        "module_name": "Accounts",
        "query": "",
        "order_by": "",
        "offset": 0,
        "select_fields": ["id", "name"],
        "link_name_to_fields_array": [],
        "max_results": 10,
        "deleted": 0
    }
}

thank you!
it is working
regards,

Mihai

1 Like