API breaks when including company in contact creation?

When a customer places an order on our site we use the API to create or update the customer in IS.

If the customer has a company name, the API call always fails. Is there something I’m doing wrong?

<cfset application.sdk.addContactStruct = structNew()/>
		<cfset application.sdk.addContactStruct["Email"] = JavaCast("string", "#variables.email#") />
		<cfset application.sdk.addContactStruct["Company"] = JavaCast("string", "#variables.companyname#") />
		<cfset application.sdk.addContactStruct["FirstName"] = JavaCast("string", "#variables.firstname#") />
		<cfset application.sdk.addContactStruct["LastName"] = JavaCast("string", "#variables.lastname#") />
		<cfset application.sdk.addContactStruct["Phone1"] = JavaCast("string", "#variables.billphone#") />
		<cfset application.sdk.addContactStruct["StreetAddress1"] = JavaCast("string", "#variables.billaddress#") />
		<cfset application.sdk.addContactStruct["City"] = JavaCast("string", "#variables.billcity#") />
		<cfset application.sdk.addContactStruct["PostalCode"] = JavaCast("string", "#variables.billzip#") />

I can’t tell which SDK you are using, but is it using the XML/RPC or REST API?

Sorry, I forgot to say that it is the XML/RPC.

Any thoughts on this?

Have you checked if this happens when the field is included (even if no name is included) or if it only happens when a value is present?

We always submit it. It only breaks when there is a value.

@Ian_at_Aquinas_and_M, I’m not familiar with the SDK that you are using, but here is a sample that works via straight XML-RPC:

<methodCall>
  <methodName>ContactService.add</methodName>
  <params>
    <param>
      <value><string>YourPrivateKey</string></value>
    </param>
    <param>
      <value><struct>
        <member><name>FirstName</name>
          <value><string>John</string></value>
        </member>
        <member><name>LastName</name>
          <value><string>Doe</string></value>
        </member>
        <member><name>Email</name>
          <value><string>there_he_go@itsjohndoe.com</string></value>
        </member>
        <member><name>Company</name>
          <value><string>ExampleCompanyName</string></value>
        </member>
      </struct></value>
    </param>
  </params>
  </methodCall>

The response I got was:

<methodResponse>
    <params>
        <param>
            <value>
                <i4>8</i4>
            </value>
        </param>
    </params>
</methodResponse>

When I view the contact through the UI, this is what I see:
Capture

@Ian_at_Aquinas_and_M,

Just so we’re up to speed, is that a .NET implementation?

It’s ColdFusion.

So, here’s the dis-connect then. You’ve introduced another variable that no one else knew about and couldn’t help with being in the dark. Since a number of us have already tested the XML-RPC with these same fields outside of any third party product and found it to work, I would remove coldfusion from the mix, test on stand alone code and, assuming you get the same results we have, start looking at why coldfusion has an issue with that one field.

1 Like

One thing to clarify first:

Should I use “company” or “company_name”?

The field name in the table is Company (cap specific)

Thanks for getting me to look more closely at the code. It was a problem after creating the variables.

You’re welcome :wink: Glad you got it worked out!

1 Like