How do I add new relationship to 2nd Bugs relationship using JSON v8 API?

Version 7.11.18. Creating relationships works great in general using the JSON API but I have having an issue. I needed bugs/meetings to have a many to many relationship so I added a new relationship (called bugs_meetings_1). If I try to create that relationship to Bugs using the API I get the following error:
“Link field has not found in Meeting to determine relationship for Bug”
The data I am sending it is just { “type”: “Bugs”, “id”: “xxx” } which works for all other relationships.

I found what appears to be a bug in the API - when you retrieve a meeting using the API you get a link for bugs (“related”: “V8/module/Meeting/xxx/relationships/bugs_meetings_1”
) but retrieving that link results in “data”: [ { “type”: “Bug”, “id”: “xxxx”, “links”: {“self”: “V8/module/Bug/xxxx” } } ]
which is an invalid link because it is …/Bug/… instead of …/Bugs/…and results in an error

When I look at the initial error received when trying to create the relationship it notice is “Link field … relationship for Bug” as opposed to “Bugs” so now I have no idea if the problem is something I am doing or something related to the invalid Bug vs Bugs.

Any help would be much appreciated. Thank you.

Hey there,

Are you still having issues with this?

I believe the CRM does use a singular/plural Module naming scheme, depending on context, which I have been caught out by myself haha

Regarding creating a relationship, I’ve had success with the following:

Create a POST request like:

{{suitecrm url}}/V8/module/{module Name}/{record ID}/relationships

And a Body like:

  "data": {
    "type": "{2nd moduleName}",
    "id": "{id of 2nd Module's record}"

So, for myself, I have a POST request like:

With the body:

Which, when submitted, will relate the Bug with ID: “717f5019-26db-aa73-21a2-5ee769f40f41”
To the Meeting with ID: “1caeb736-50e5-bd1a-9233-5ee7699b8c73”

Is that what you’re looking to achieve?

Not quite. This works when adding a relationship to the Bugs module using the default relatiionship. However, in my case I needed bugs to have a many-to-many relationship rather than a one-to-may relationship as is the default. Since you can’t edit a default relationship I created a second Meetings-Bugs relationship called bugs_meetings_1. But since the JSON body refers only to the module name Bugs, not the relationship name, their does not seem to be any way to create the second relationship rather than the first.

I got around the problem by creating a whole new custom bugs module and relating to that instead. It seems odd to me that you can’t post something by relationship name rather than module name. I have the same issue with adding a user to a meeting. There are 3 different user-meeting relationships and so a JSON post to add a user to a meeting fails. For that issue I ended up just directly updating the meetings-users table which is a terrible solution but API bugs don’t ever seem to get fixed and there’s no point in having a meeting if nobody is invited.


Thank you for detailing your workaround solution!

I would still suggest raising this on the Github Repo, so that it can be tracked as a suggested addition
(As you’ve noted a very good point about the API using Module Names, rather than relationship-types)

But, thank you for getting back in touch! :slight_smile: