Page MenuHomePhabricator

Revise WME website form submit API
Closed, ResolvedPublic1 Estimated Story Points

Description

We're revising how the form data will need to be submitted to the CRM from this original ticket: https://phabricator.wikimedia.org/T292133
Currently we're sending a POST to /developer_api/v1/people but that's changing to Leads. Due to that we need to format the request object a little bit and change the method.

PUT URL: (note: method is not POST anymore)
@see: https://developer.copper.com/leads/upsert-a-lead.html
PUT https://api.copper.com/developer_api/v1/leads/upsert

POST HEADERS: (note: nothing changes here from OP)

POST BODY:
For reference here I used double-brackets to represent variable data and left the static info as is.
{{form_input_*** and {{form_textarea_*** are content submitted via the form.
{{siteurl_path_form_is_on}} is the URL path where the form was filled out on. Everything else is static and just copy/pasta.

{
  "properties": {
    "name": "{{form_input_name}}",
    "assignee_id": 912228,
    "company_name": "{{form_input_company_name}}",
    "email": { 
      "email": "{{form_input_email}}", 
      "category": "work"
    },
    "custom_fields": [
        {
            "custom_field_definition_id": 505797,
            "value": "{{form_textarea_usecase}}"
        },
        {
            "custom_field_definition_id": 505798,
            "value": "{{siteurl_path_form_is_on}}"
        }
    ]
  },
  "match": {
    "field_name": "email",
    "field_value": "{{form_input_email}}"
  }
}

Event Timeline

Alexander.lauie changed the task status from Open to In Progress.Nov 23 2021, 10:31 AM

@creynolds hi, please, check how API works on the dev site https://dv.enterprisewikimedia.com/

One thing I've noticed, but I'm not sure whether it's an issue.
Previously the same email could be used only once while submitting the form, now this validation has gone and the same email address can be submitted many times

Previously the same email could be used only once while submitting the form, now this validation has gone and the same email address can be submitted many times

That's a feature not a bug; because we're using a new endpoint they allow an "upsert" which will "match" on the previous email (see OP json object for reference) so it will no longer error in that regard like the old 'people' endpoint did. So that's not a problem.

As far as testing goes... I see the info does PUT to Copper but the browser throws a 400 in console. See attached.

Screen Shot 2021-11-29 at 11.14.18 AM.png (1×766 px, 184 KB)

Screen Shot 2021-11-29 at 11.12.58 AM.png (1×1 px, 240 KB)

to repro... just load /get-started/ page and hit submit.

AnnaMikla changed the task status from In Progress to Open.Dec 8 2021, 11:47 AM