Topic
  • 2 replies
  • Latest Post - ‏2012-06-23T02:30:58Z by SystemAdmin
SystemAdmin
SystemAdmin
570 Posts

Pinned topic Error while invoking HTTP Adapter

‏2012-06-23T02:00:26Z |
When I invoke the HTTP Adapter procedure using Eclipse > Run As > Invoke Worklight Procedure, I got the below results

Invocation Result of procedure: 'searchConsultant' from the Worklight Server:

{
"consultant": [
{
"currentAddress": "1601-1645 Market St",
"currentCity": " San Francisco",
"currentCountry": " USA",
"currentState": " CA",
"currentZipcode": " 94103",
},
{
"currentAddress": "101 Blue Lagoon Dr",
"currentCity": " Miami",
"currentCountry": " USA",
"currentState": " FL",
"currentZipcode": " 33126",
}
],
"isSuccessful": true,
"statusCode": 200,
"statusReason": "OK"
}

But When I access through code, I got the following error

Code:

{
var consultantSearchURL = '/ResourceLocatorPortlet/rest/consultant/searchConsultant?searchCriteria=' + filterName + '&criteriaValue=' + filterValue;

var parameters = new Object();
parameters = consultantSearchURL;

var invocationData = {
adapter : 'ResourceSearch',
procedure : 'searchConsultant',
parameters : parameters
};
var options = {
onSuccess : displayConsultants,
onFailure : displayProcedureError
};
WL.Client.invokeProcedure(invocationData, options );
}

function displayConsultants(result){
var consultantList = result.invocationResult.consultant;

for(var index = 0 ; index< consultantList.length; index++){
var currentConsultant = consultantListindex;
var currentConsultantAddressStr = currentConsultant.currentAddress +", "+currentConsultant.currentCity +", "+currentConsultant.currentState +", "+currentConsultant.currentCountry;
}
}
Error:
"Procedure invocation error. J S O N: A JSONArray text must start with '[' at character 1"

Any idea?

Thanks
  • MikeZilbergleyt
    MikeZilbergleyt
    10 Posts

    Re: Error while invoking HTTP Adapter

    ‏2012-06-23T02:25:51Z  
    What did you pass as input to the Run As?

    I think the "parameters : parameters" which be an JSON array.

    Mike Z
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: Error while invoking HTTP Adapter

    ‏2012-06-23T02:30:58Z  
    What did you pass as input to the Run As?

    I think the "parameters : parameters" which be an JSON array.

    Mike Z
    I passed the parameter as '/ResourceLocatorPortlet/rest/consultant/searchConsultant?searchCriteria=REGION&criteriaValue=West'

    And in the code I tried with string parameter as well as object parameter.