Multi Select box sent via API showing value as Array()

  • 0
  • 1
  • Question
  • Updated 5 years ago
  • Answered
  • (Edited)
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members.

When posting values of a multi select box via the API, Emma shows the value as "Array()" . All other plain text values are being passed correctly.  I manually filled out a form on the MyEmma site,  checked the Emma response via the API, and the values were returned as an array.  
Photo of Mat Jones

Mat Jones

  • 6 Posts
  • 2 Reply Likes

Posted 5 years ago

  • 0
  • 1
Photo of Tyler Scott

Tyler Scott, Employee

  • 805 Posts
  • 39 Reply Likes
Hey there! We don't offer support for the API as the technical level is definitely out of our realm. We're more experts on the Emma app itself and leave the developer work to the experts such as yourself. Can you please let me know though what API call you're using to pull that data? I'll do my best to help! 
Photo of Tyler Scott

Tyler Scott, Employee

  • 805 Posts
  • 39 Reply Likes
Good morning Mat! I wanted to be sure you saw my post above. Please just give me a shout if you still need assistance.

Thanks!
Photo of Mat Jones

Mat Jones

  • 6 Posts
  • 2 Reply Likes
It is just a fairly standard CURL posting function that we have used on all of our sites.  We have used it without issue for years, but one of our forms has a multi-select option.  For some reason the array value is not being interpreted correctly.

I guess I am just wondering if there is any trick when a form value is a multi-select option. As stated above when I manually filled out a form on the MyEmma site,  checked the Emma response via the API, and the values were returned as an array.  One would assume when posting they also need to be an array. 
Photo of Matt T.

Matt T., Official Rep

  • 75 Posts
  • 32 Reply Likes
Hi Mat,

I think I'm following the question here. I'm one of the project managers for our development team, so I thought I'd try to answer. 

They do indeed need to be passed as an array. The key is the shortcode for the field, and the options need to be passed as an array of strings. The options must match in value and case in order for this to work properly. 

This is certainly not well stated in our documents, so we can understand the confusion here. We'll get this on our list for updating in the near future. 

Thanks!
Photo of Ajjaykummar Naagley

Ajjaykummar Naagley

  • 8 Posts
  • 0 Reply Likes
Sorry to jump here
How do we pass the options? You said the options need to be passed as an array of string
so suppose I have the following options 
Being a role model for my young children
Talking to my pre-teen about responsible decision-making
Teaching my teenager about safe driving

So how do I pass the array of options.. would it be (considering 1st two options are selected)
array("Being a role model for my young children","Talking to my pre-teen about responsible decision-making")
or would it be
array("being-a-role-model-for-my-young-children","talking-to-my-pre-teen-about-responsible-decision-making")

If we are supposed to use shortcodes then where do I find this shortcodes for the options
Meanwhile I am using http://api.myemma.com/php_signup_example.html 
Regards
Photo of Ajjaykummar Naagley

Ajjaykummar Naagley

  • 8 Posts
  • 0 Reply Likes
I was able to solve the problem using the checkbox label as option
I used
array("Being a role model for my young children","Talking to my pre-teen about responsible decision-making")

and the field is getting saved