David Adams Posted July 7, 2023 Posted July 7, 2023 Thank you in advance for your help with this! Hi we have just started using the Sage API and were able to create a customer. However, when we attempt to populate the address and contact info we get a "MalformedRequestBody" error. I think the syntax is correct and all of the PHP variables contain the appropriate data, so I'm thinking there must be a required field that is missing such as "type ID" or some other required field. here is the block of code that is causing the error: CURLOPT_POSTFIELDS => '{ "contact": { "name": "' . $company . '", "contact_type_ids": [ "Customer" ], "main_address": { "address_line_1": "' . $street1 . '", "address_line_2": "' . $street2 . '", "city": "' . $city . '", "postal_code": "' . $zip . '", "region": "' . $state . '", "is_main_address": true }, "delivery_address": { "address_line_1": "' . $street1 . '", "address_line_2": "' . $street2 . '", "city": "' . $city . '", "postal_code": "' . $zip . '", "region": "' . $state . '", "is_main_address": false }, "main_contact_person": { "name": "' . $firstname . ' ' . $lastname . '", "job_title": "' . $title . '", "telephone": "' . $phone . '", "mobile": "' . $mobile . '", "email": "' . $email . '", "is_preferred_contact": true } }',
David Adams Posted July 7, 2023 Author Posted July 7, 2023 i added country_group_id with a value of "US" to the two address blocks.. not sure if this was required or correct.. but still no luck (example below) "main_address": { "contact_id": "' . $custObj->contact_id . '", "address_line_1": "' . $street1 . '", "address_line_2": "' . $street2 . '", "city": "' . $city . '", "postal_code": "' . $zip . '", "region": "' . $state . '", "country_group_id": "' . 'US' . '", "is_main_address": true },
David Adams Posted July 8, 2023 Author Posted July 8, 2023 any advice from anyone? the syntax seems great and the variables are all properly filled with correct data and data types. it has to be a required field or some other technicality i think... anyone?
David Adams Posted July 9, 2023 Author Posted July 9, 2023 PROBLEM SOLVED! -- Thank you everyone who spent any time reviewing turns out I was (ugh) missing a closing bracket on an array element, and also missing TWO required fields as part of each address: "address_type_id": "ACCOUNTS", "name": "Main Address", Ok, live and learn... closing this topic... thanks again.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now