Software Archive
Read-only legacy content
17061 Discussions

Intel XDK web services parameter types Array

Qiang_L_1
Beginner
190 Views

Hi, 

I try to create web service method to upload parameter as JSON data through Ajax POST.

It is working fine with a single "string" parameter, but not "Array" type.

Could anyone help?

This is the mywebservicemethod.json file:

{
"endpoints": [
  {
    "name": "Update interests catergories",
    "methods": [
      {
        "MethodName": "updateInterests",
        "Synopsis": "Update interests",
        "parameters": [
          {
            "Name": "newInterestedCategories",
            "Required": "Y",
            "Default": [],
            "Type": "array",
            "Description": "categories array"
          }
        ]
      }
    ]
  }
]
}

And in mywebservicemethod.js file, I try to read parameter:

var categories = params.newInterestedCategories;

in ajax call, it is converted to JSON:

data: JSON.stringify( {"newInterestedCategories":categories} ),

Under Explore Services, I typed in ["News"] as Value of parameter.

In the end, the ajax call send this as captured by Fiddle:

{"newInterestedCategories":"[\"News\"]"}

What I want is {"newInterestedCategories":["News"]}

By the way, angularjs is referenced in the project.

Thanks very much!

Qiang

 

0 Kudos
0 Replies
Reply