APICloud调用OpenApi设备分享求助
调用post类,总是返回400,说9015错误,但是这类参数要怎么传呢?直接传obj不行,拼接起来传也不行,求老司机指点var ajax = ajaxObject();
var obj = new Object();
obj.type = 1;
obj.did = did;
var data = "type="+obj.type+",did="+obj.did";
if(ajax)
{
var url = "https://api.gizwits.com/app/sharing";
ajax.open( "post" , url , true );
ajax.setRequestHeader( "Content-Type" , "application/json" );
ajax.setRequestHeader( "Accept" , "application/json" );
ajax.setRequestHeader( "X-Gizwits-Application-Id" , appid);
ajax.setRequestHeader( "X-Gizwits-User-token" , token);
ajax.onreadystatechange = function () {
if( ajax.readyState == 4 ) {
if( ajax.status == 200 ) {
alert( ajax.responseText );
}
else {
alert( "HTTP请求错误!错误码:"+ajax.status+"txt="+ajax.responseText );
}
}
else {
//fnLoading();
}
}
ajax.send(data);
}
有解吗? 我也碰到一样的问题 不用自己写ajax,APICloud平台有封装好的ajax方法。
api.ajax({
url: 'https://api.gizwits.com/app/sharing',
method: 'post',
headers: {
'Content-Type': 'application/json',
'Accept':'application/json',
'X-Gizwits-Application-Id': appid,
'X-Gizwits-User-token': token
},
data: {
body:{'type':0,'did':did,'phone':phone}
}
}, function(ret, err) {
}); Towery 发表于 2017-11-29 23:35
有解吗? 我也碰到一样的问题
不用自己写ajax,APICloud平台有封装好的ajax方法。
api.ajax({
url: 'https://api.gizwits.com/app/sharing',
method: 'post',
headers: {
'Content-Type': 'application/json',
'Accept':'application/json',
'X-Gizwits-Application-Id': appid,
'X-Gizwits-User-token': token
},
data: {
body:{'type':0,'did':did,'phone':phone}
}
}, function(ret, err) {
});
页:
[1]