SOLVED

REST API - Field name differences between form description and submitForm

Go to solution
Avenirer
Level 1

REST API - Field name differences between form description and submitForm

Hello,

I am trying to submit forms from backend (REST API). But I am facing a weird behavior related to the field namings. When I access the "fields.json" endpoint for a specific form, one of the fields I receive is "Email":

 

 

{
  "id": "Email",
  "label": "E-mail Address",
  "dataType": "email",
  "validationMessage": "Must be valid email. <span class='mktoErrorDetail'>example@yourdomain.com</span>",
  "rowNumber": 0,
  "columnNumber": 0,
  "required": true,
  "formPrefill": true,
  "visibilityRules": {
    "ruleType": "alwaysShow"
  }
}

 

 

But when I try to upsert a lead using the submitForm.json endpoint using the same specific form, I cannot update/insert the lead unless I use the "email" field, and not the "Email" field.

This does not work (Field 'Email' not found in form definition):

 

 

{
    "input":
    [
        {
            "leadFormFields":
            {
                "Email": "example@example.com"
            }
        }
    ],
    "formId":"2509"
}

 

 

 

This works:

 

 

{
    "input":
    [
        {
            "leadFormFields":
            {
                "email": "example@example.com"
            }
        }
    ],
    "formId":"2509"
}

 

 

 Am I doing something wrong, considering that other fields that are mentioned in the fields.json are updated correctly in submitForm?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: REST API - Field name differences between form description and submitForm

There is no longer any support for a "form post from backend" as in "HTTP POST with an x-www-formurlencoded body".  No direct solution exists.

 

You may instead make an API call to the Submit Form API endpoint, which uses the standard REST API semantics (obtaining an expiring access_token and so on). As a REST endpoint, the Submit Form API naturally expects REST API field names. This makes it unlike an actual form post, which uses SOAP field names. REST field names are available using the Describe Lead endpoint.

 

A Submit Form API call results in a Filled Out Form activity in the lead's Activity Log, which can be acted on in the same way as a true form post. Nevertheless, the request you put on the wire is not a form post.

View solution in original post

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: REST API - Field name differences between form description and submitForm

Submit Form uses REST names. It's not a way to send a Marketo form post; it's a way to send a payload that creates a Filled Out Form activity.

Avenirer
Level 1

Re: REST API - Field name differences between form description and submitForm

How can I send a form post from backend. If we have a REST API, is there a way for me to fill a form using it?

SanfordWhiteman
Level 10 - Community Moderator

Re: REST API - Field name differences between form description and submitForm

There is no longer any support for a "form post from backend" as in "HTTP POST with an x-www-formurlencoded body".  No direct solution exists.

 

You may instead make an API call to the Submit Form API endpoint, which uses the standard REST API semantics (obtaining an expiring access_token and so on). As a REST endpoint, the Submit Form API naturally expects REST API field names. This makes it unlike an actual form post, which uses SOAP field names. REST field names are available using the Describe Lead endpoint.

 

A Submit Form API call results in a Filled Out Form activity in the lead's Activity Log, which can be acted on in the same way as a true form post. Nevertheless, the request you put on the wire is not a form post.

Avenirer
Level 1

Re: REST API - Field name differences between form description and submitForm

Wonderful. So, you're telling me that, if i find a way to associate soap fields with the rest fields, I can then upsert leads using the form fields?

SanfordWhiteman
Level 10 - Community Moderator

Re: REST API - Field name differences between form description and submitForm

That's correct. As the docs mention, you use REST API names. The Describe Endpoint lists both REST and SOAP aliases, as does a field export from the Field Management UI.

 

SanfordWhiteman_0-1620886507613.png

Avenirer
Level 1

Re: REST API - Field name differences between form description and submitForm

Thank you very much for help.

Prashanth_K
Level 2

Re: REST API - Field name differences between form description and submitForm

I am using the following body to hit the submit form API. 

 

{
  "input": [
    {
      "leadFormFields": {
        "email": "marge.simpson@fox.com"
      }
    }
  ],
  "formId": 1012
}

 

I am getting the following error. 
 

 

 "result": [
        {
            "status": "skipped",
            "reasons": [
                {
                    "code": "1006",
                    "message": "Field 'email' not found in form definition"
                }
            ]
        }
    ],
    "success": true

 

 The same request worked last week but I am facing the above error even after giving the REST names. What could be the cause? 

PS: As this is a related post, I have posted the comment here.

SanfordWhiteman
Level 10 - Community Moderator

Re: REST API - Field name differences between form description and submitForm

Can you show a screenshot of the Form Editor for form ID 1012, with Email Address on the form? (Also make sure you haven't cloned the form to another ID.)

Prashanth_K
Level 2

Re: REST API - Field name differences between form description and submitForm

Got it, I forgot to add the fields in the form. 
Thanks much!