Linking a contact to a customer third party via REST API

Hi,

I am wondering if it is possible. I specify both socid and fk_soc fields in the JSON payload, but it seems that they are ignored.

Kind regards

1 Like

I do it using Python, Flask and the API.

I have a form that I use to have dance students register for dance classes in our little non profit. The form system finds the services inside Dolibarr, and exposes the right fields, text, questions, options, … based on settings inside Dolibarr service area. I could probably might as well use products, but when I made things by hand the products needed sizes and weight where as services does not.

After validating the form data I

  1. find a thirdparty using the email
  2. if none is found add a thirdparty (and a member if that is required and/or the registrant opted for becoming a member
  3. then I add a contact. I always add a contact, even if there is already a contact. The plan is to compare the contacts and if there are changes in name, phone, address, then I either ask the registrant during registration which one to use, or better yet, I send them an email asking them which one to use. But I haven’t coded this yet.
  4. I also want to add that contact as the contact for the registration, but I haven’t done that yet.
  5. I create a proposal even before the registrant verifies their registration, this is so I can see anyone who is left stranded.
  6. upon registrant confirmation I validate the proposal, which could trigger an email being sent to registrant about their registration details. So far I manually add that notification for each and every thirdparty :frowning:
  7. also at confirmation I create a draft sales order.
  8. when I or one of the other teachers want to accept a student into class, I validate that order, and they are sent an email asking them to pay.
  9. when paying an invoice is created.

I used the API explorer to figure out the minimum json that was needed to create a contact. Here’s what I found:

TEMPLATE_CONTACT_DICT = {
“entity”: “1”, # Ministry of Balboa
“lastname”: “”, # insert last_name here
“firstname”: “”, # insert first_name here
“email”: “”, # insert email here
“mail”: “”, # insert email here
“phone_mobile”: “”, # insert tel_one here
“address”: “”, # insert address here
“socid”: “” # insert thirdparty_id here
}

Many thanks. I create support accounts for allowing access to the ticket system.

Providing only socid seems to make it:

{
“lastname”: “Support-ABC”,
“email”: "helpdesk@x.y,
“socid”: “nn”
}