Announcement

Collapse
No announcement yet.

Posting JSON with MVT:CALL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Posting JSON with MVT:CALL

    I'm trying to post some simple JSON (to the Mailchimp API), but I get back and error that says what I'm sending is NULL. Here's the code:

    Code:
    <mvt:assign name="g.list_id" value="'d579b341b9'" />
    <mvt:assign name="g.tag_url" value="'https://us2.api.mailchimp.com/3.0/lists/'$ g.list_id $'/segments/21/members'" />
    <mvt:assign name="g.add_email" value="'{  \"email_address\": \"[email protected]\"}'" />
    <mvt:assign name="g.headers" value="'Authorization: Basic xxxxxxxxxxxxxxxxxx' $ asciichar( 13 ) $ asciichar( 10 )" />
    
    <mvt:call action="g.tag_url" method="'POST'" fields="g.add_email" content-type="'application/json'" headers="g.headers" >
    <mvt:eval expr="s.callvalue" />
    Yields the error:
    "errors":[{"field":"","message":"Schema describes object, NULL found instead"}]
    </mvt:call>
    I tried encoding the JSON as well, but that didn't work. Do I need to prepare the data in some other form?

    Any help greatly appreciated.

    Best,
    Paul
    Last edited by paul.oreilly; 06-15-19, 04:55 AM.

    #2
    You probably need to set your method to 'RAW' and fields should be a comma separated list of variables, but you are passing it a data value directly. Meaning you should be doing fields="'g.add_email'" I believe. Also I recommend editing your post and removing your authorization token, anyone could potentially use that token and impersonate your or read your data.
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      Thank You! Method as RAW, and wrapping the fields as a string did it. Removing my token from this post, also a good idea!

      Comment

      Working...
      X