Postman get_entries

Hi all,

I am trying to make an connection with postman.
So far I am able to login, get the session id, get_entry, get_entry_list.
Only the get_entries I cannot figure out what the correct syntax would be.

url = https://www.mydomain.org/crm/service/v4_1/rest.php
method = get_entries
input_type = JSON
response_type = JSON
rest_data = {“session” : “mysessionid”,“module_name” : “Users”,“ids” : {“id-of-the-user”},“select_fields” : {""},“link_name_to_fields_array” : {""} , “track_view” : “true”}
Using the latest stable version.

With kind regards,

Charles

Hello, I’m trying to get_entry_list with postman but the response is null
{“session”:“MySessionId”,

“module_name”:“Contacts”,

“query” :’’,

“order_by”:"",

“offset”:“0”,

“select_fields”:{“id”,“first_name”,“last_name”},

“max_results”:“2”

}
don’t know what i’m doing wrong ?
Do u have any idea
Thanks

Hi,
try

{
		"session": "MySessionId",
		"module_name":"Contacts",
		"query":null,
		"order_by": null,
		"offset": null,
		"select_fields": [
			"id", "first_name", "last_name"
		],
		"link_name_to_fields_array": null,
		"max_results": 2
}

instead. From my perspective, the biggest problem was this part:

“select_fields”:{“id”,“first_name”,“last_name”},

→ “select_fields” is an array/list and not an object, therefore [ and ] instead of { }

1 Like

thanks alot it worked

I’m trying to add a query to this function to select a unique name like this : “query” :" first_name=‘chayma’ "
and abviously it’s not correct.
would you have any suggestions
Thanks

Hi,
I’m just on my mobile, but it should work like this:

If its not working, I’ll copy a tested example tomorrow from my notebook.

E: tested and working:

{
		"session": "sessionid",
		"module_name":"Contacts",
		"query": "contacts.first_name='someName'",
		"order_by": null,
		"offset": null,
		"select_fields": [
			"id", "first_name", "last_name"
		],
		"link_name_to_fields_array": null,
		"max_result": 2
}

Hello back,
yes it’s working
thank you so much

Hello again, i’m digging deeper into queries, i wanted to ask how can i use relationships, for example i want to select contact id using the email adresse of that contact…

this is my try
{“session”:“MySessionId”,

“module_name”:“Contacts”,

“query” :“contacts JOIN email_adresses.email_adress=‘myadress@gmail.com’”,

“order_by”:null,

“offset”:“0”,

“select_fields”:[“id”],

“link_name_to_fields_array”: null,

“max_results”:“4”

}

i get 500 error code with this response : Database failure. Please refer to suitecrm.log for details.

Tricky question, mail addresses are not stored directly in the bean. What I can show you is how to retrieve the related mail address though:

{
		"session": "{{sessionid}}",
		"module_name":"Contacts",
		"query": "contacts.id='someId'",
		"order_by": null,
		"offset": null,
		"select_fields": [
			"id", "first_name", "last_name"
		],
		"link_name_to_fields_array": [
		{
			"name": "email_addresses",
			"value": [
				"id",
				"email_address",
				"opt_out",
				"primary_address"
			]
		}
		],
		"max_result": 1 
}

The problem with the query-parameter: it only contains the “where” statement of the query, so it’s not possible to enter joins directly. Instead, you can retrieve related records by using the “link_name_to_fields_array”.

Technically, it should therefore be possible to retrieve the mail addresses first and then filter for the specific mail to return the contact.
Approach:

{
		"session": "{{sessionid}}",
		"module_name":"EmailAddresses",
		"query": "email_addresses.email_address='demo@example.com'",
		"order_by": null,
		"offset": null,
		"select_fields": [
			"id", "email_address"
		],
		"link_name_to_fields_array": [
		
		],
		"max_result": 2
}

→ would return the specific emailaddresses-object and its ID. The last step is now to load the related contact too, but I wasn’t able to figure out the correct link name. But maybe someone else here is able to help.

1 Like

I’m trying this query that seems to give me back 200 response code but the entry list is empty.
Ps the adresse mail that i’am passing exist in the db

        {
         
           "session":"{{sessionid}}",

          "module_name":"Accounts",

          "query":" accounts.id IN ( SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN 
                    email_addresses ea ON (ea.id =eabr.email_address_id) WHERE eabr.bean_module = 
                    'Accounts' AND eabr.deleted = 0 AND ea.email_address = 'myadresse@gmail.com')",

          "order_by":null,

          "offset":"0",

          "select_fields":["id"],

          "link_name_to_fields_array": null,

          "max_results":"4"  }