简体   繁体   中英

How To Pass JSON to a WebGet

I have the following WebGet:

    [WebGet(UriTemplate = "GetAssignments/{data}")]
    [Description("GetAssignments")]
    BASE.BaseResponse<object> GetAssignments(String data); 

Called thusly:

    var data = JSON.stringify(advancedSearchDataXml);

    Helper.Service.Call({
        api: 'HomeApi',
        url: '?method=GetAssignments/' + data,
        method: 'GET',
        //data: advancedSearchDataXml,
        controlId: '',
        showProgress: true,
        onSuccess: function (result) {
    ...

where data is

{"searchquery":
    "<SearchQuery>
        <genericsearch></genericsearch>
        <region>MA</region><market>RL</market>
        <recordcount>5000</recordcount>
    </SearchQuery>"
}

This fails with a "EXCEPTION: The remote server returned an error: (400) Bad Request" message. What am I doing wrong?

尝试删除?method=而仅使用'GetAssignments/'+ data ..还要在控制器中添加一个断点,以确保正确的方法被'GetAssignments/'+ data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM