AnsweredAssumed Answered

Insert from URL - sub-objects in JSON-data are not passed to Mailchimp-webservice

Question asked by Menno on Jun 4, 2017
Latest reply on Oct 28, 2017 by PuraVida

Product and version FileMaker Advanced 16.0.1

OS and version MacOSX10.12.5 and Windows 10 Pro x64

Browser and version (for WebDirect only)

Hardware Mac, HP

Description Sub-objects in JSON in data-part in cURL-options for Insert From URL are not passed to the webservice See discussion below

How to replicate See explanation below

Workaround use the command line as indicated below

 

 

I am trying to add subscribers to a mailing-list on mailchimp. The cURL-command to do that is:

curl --request POST \

--url 'https://us6.api.mailchimp.com/3.0/lists/b123456789/members' \

--user 'myaddress@example.com:4d5751ea6cccc12345678902d4a01297-us6' \

--data '{"email_address":"user@example.com","status":"pending","email_type":"html","merge_fields":{"FNAME":"FirstName","LNAME":"LastName"}}'

If I translate this into "Insert from URL" it becomes:

Insert from URL [ gResult ; "https://us6.api.mailchimp.com/3.0/lists/b123456789/members" ; curl-options:

--request POST \

--user myaddress@example.com:4d5751ea6cccc12345678902d4a01297-us6 \

--data {"email_address":"user@example.com","status":"pending","email_type":"html","merge_fields":{"FNAME":"FirstName","LNAME":"LastName"}}

The response from mailchimp then is:

{
    
"detail": "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
    
"errors": [{
        
"field": "",
        
"message": "Schema describes object, NULL found instead"
    
}],
    
"instance": "",
    
"status": 400,
    
"title": "Invalid Resource",
    
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/"
}

This result is caused by the "merge_fields"-object, so when I remove that object from the data-part, the subscriber will be created, however without the merge-fields. The response (shortened) from mailchimp is:

 

{
     "id": "0264DB24CF12C037690758132A4BD5B8",
     "email_address": "myaddress@example.com",
     "unique_email_id": "0123456789",
     "email_type": "html",
     "status": "subscribed",

    
"merge_fields": {
         "FNAME": "",
         "LNAME": ""
     },

     "stats": {
         "avg_open_rate": 0,
         "avg_click_rate": 0
     },
     "ip_signup": "",
     "timestamp_signup": "",
     "ip_opt": "127.0.0.1",
     "timestamp_opt": "2017-06-04T23:02:38+00:00",
     "member_rating": 2,
     "last_changed": "2017-06-04T23:02:38+00:00",
     "language": "",
     "vip": false,
     "email_client": "",
     "location": {
         "latitude": 0,
         "longitude": 0,
         "gmtoff": 0,
         "dstoff": 0,
         "country_code": "",
         "timezone": ""
     },
     "list_id": "b123456789",
     "_links": [
         {
             "rel": "self",
             "href": "https://us6.api.mailchimp.com/3.0/lists/b123456789/members/0264DB24CF12C037690758132A4BD5B8",
             "method": "GET",
             "targetSchema": "https://us16.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Response.json"
         }
     ]
}

 

 

If I use the command line and send the command as in the first quote-block above the same subscriber is created with the merge-fields. The response (shortened) form mailchimp then is:

{
     "id": "0264DB24CF12C037690758132A4BD5B8",
     "email_address": "myaddress@example.com",
     "unique_email_id": "0123456789",
     "email_type": "html",
     "status": "subscribed",

    
"merge_fields": {
         "FNAME": "FirstName",
         "LNAME": "LastName"
     },

     "stats": {
         "avg_open_rate": 0,
         "avg_click_rate": 0
     },
     "ip_signup": "",
     "timestamp_signup": "",
     "ip_opt": "127.0.0.1",
     "timestamp_opt": "2017-06-04T23:02:38+00:00",
     "member_rating": 2,
     "last_changed": "2017-06-04T23:02:38+00:00",
     "language": "",
     "vip": false,
     "email_client": "",
     "location": {
         "latitude": 0,
         "longitude": 0,
         "gmtoff": 0,
         "dstoff": 0,
         "country_code": "",
         "timezone": ""
     },
     "list_id": "b123456789",
     "_links": [
         {
             "rel": "self",
             "href": "https://us6.api.mailchimp.com/3.0/lists/b123456789/members/0264DB24CF12C037690758132A4BD5B8",
             "method": "GET",
             "targetSchema": "https://us16.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Response.json"
         }
     ]
}

 

So the problem is that adding

,"merge_fields":{"FNAME":"FirstName","LNAME":"LastName"}

to the data-part in FM result in an error, where the same addition on the command line works perfectly and adds a new subscriber. Is this a bug in "insert URL" or am I doing something wrong?

Outcomes