Working API V8 Relationship Example?

I’m trying to use the V8 Api with SuiteCRM 8. So far so good. I can get my access token, I can query a list of cases, but when I try to use a relationship query, nothing seems to work.

I’m doing this:

GET{suitecrm URL}/Api/V8/module/Contacts/128183a9-404c-77e7-b0bb-67858ddbe917/relationships/cases

The documentation says:

GET {{suitecrm.url}}/Api/V8/module/{moduleName}/{id}/relationships/{linkFieldName}

The example given is this:

Api/V8/module/Accounts/129a096c-5983-1d59-5ddf-5d95ec91c144/relationships/members

Is anyone using the V8 API to fetch related records? Am I missing something?

I’m thinking it can only grab one to many relationship and not a many to many relationship. There is no {linkFieldName} in a many to many. Is this even supported or do I have to query it differently?

Hi Paul,

'example.com/legacy/Api/V8/module/Accounts/' . $accountId . '/relationships/relationship_name_1'

works for me.

The name of the relationship was key for me. It’s the link name showing in a file, I am certain I’ve read this somewhere in the docs or similar but I’m not able to find it anymore just now.

As for the many to many:
Did you build this out via a mapping module?
For a direct many to many without mapping module, I haven’t found an example in my code here.

Thanks @BastianHammer I couldn’t find any examples either. Im thinking its not possible. Im trying to build a WordPress plugin and I was hoping to built it 100% on the wp side. I guess I could build a custom endpoint in SuiteCRM but I was hoping I didn’t have to do that. You would think the stock API should be able to handle this.

Ok this one was a “PICNIC” problem = “Problem in Chair Not in Computer”

I was connected one dev SuiteCRM for testing the code and a different one for testing Postman!!!

When I finally realized this it works as expected. It is wierd that the token submitted was for a different installation. I would have thought I should have got returned “not authorized” rather than a 400, but I got it working.

https://{my istall directory and tld}/Api/V8/module/Contacts/4199f8ef-7a55-08fe-8834-6675828537b4/relationships/cases

It returns a list of cases Contact is associated with.

2 Likes