No announcement yet.

Posting JSON with MVT:CALL

  • 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:

    <mvt:assign name="g.list_id" value="'d579b341b9'" />
    <mvt:assign name="g.tag_url" value="''$ 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"}]
    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.

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

  • 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


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



      This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

      This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.