Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Qiang_L_1
Beginner
50 Views

Intel XDK web services parameter types Array

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

 

Tags (2)
0 Kudos
0 Replies
Reply