Set relationship SugarCRM (SuiteCRM) via Rest API between Accounts and a custom module

I’m trying to create a relationship between two modules, Accounts and another custom module that I called it “Estadisticos” and the final module name for SuiteCRM is “Mk902_Estadisticos”. I’ve inserted data fine in the module via REST API but now I’m trying to create a relationship between these records with Accounts module, and the code I’m using is the same that i’ve used to succesfully between another modules as contacts with accounts, but in this case is not woprking for me sending me back this:

{"created":0,"failed":1,"deleted":0}

This is the code that works fine for default modules but not for custom modules

Map<String, Object> tmpHash = new LinkedHashMap<String, Object>();
List<String> tmpRelatedIds = new ArrayList<String>();
tmpRelatedIds.add(aRelatedId);

tmpHash.put("session", this.getSessionId());
tmpHash.put("module_name", METHOD_NAME);
tmpHash.put("module_id", anId);
tmpHash.put("link_field_name", aMethodRelated.toLowerCase());
tmpHash.put("related_ids", tmpRelatedIds);

JSONObject tmpRetreivedData = this.callWS("set_relationship", tmpHash);

if(tmpRetreivedData != null && tmpRetreivedData.size() > 0){
    System.out.println(tmpRetreivedData.toJSONString());
    return tmpRetreivedData;    
}
else{
    return null;
}

Maybe I can’t create relationships via REST using a custom module?

NOTE: I’m coding in JAVA but PHP help could be useful too

Thanks a lot!

Hi,

You should be able to use the REST API to add relationships to custom modules.

Can you provide an example of the fields you are sending? Note that link_field_name is not the relationship name - rather this is the name of the link field within the module.

Thanks,
Jim