【发布时间】:2015-12-19 01:26:54
【问题描述】:
首先我无法控制 API 是如何构建的,我需要做的只是调用它。
现在我需要传入以下内容,如下所示:
{
"ConsumerAggregatedAttributes": [
{
"ConsumerAggregatedAttributeID": 28,
"ConsumerID": "1159040334",
"ApplicationCode": "36363636",
"LocaleCode": null,
"AttributeCode": "FailedLoginAttemps",
"Value": "0",
"CreateTS": "2015-12-14 23:53:30.517",
"UpdateTS": "2015-12-15 01:12:06.947"
}
],
"ConsumerID": "1159040334",
"PersonalQRImageGUID": "a30d62db-0981-4b7c-bed0-4cf66d2fe1a3",
"PictureMediaGUID": null,
"Nickname": "testing",
"LastGPSCoordinate": null,
"TotalCredit": 0,
"AvailableCredit": 0,
"IsActive": true,
"IsPictureApproved": false,
"Firstname": "test",
"Lastname": "test",
"Username": "test.email@test.com.au",
"Password": null,
"Email": "test.email@test.com.au",
"Mobile": "04145588774",
"Address": null,
"City": null,
"Province": null,
"PostalCode": null,
"Country": null,
"DateOfBirth": null,
"Gender": null,
"Language": null,
"CreateTS": "2015-12-14 23:51:27.143",
"UpdateTS": "2015-12-15 01:17:22.567",
"ConsumerTypeCode": "Admin",
"DefaultLocaleCode": "EN",
"IsTestUser": false,
"Distance": null
}
现在我的 ajax 调用看起来像这样:
$http({
method: 'POST', url: 'https://someUrl.com/servicecol.svc/updateProfile?$expand=ConsumerAggregatedAttributes&LocationID=1&Role=Manager&IsProfileComplete=True', headers: {
t: ts, // Time Stamp
vt2: hashInBase64,// Encrypted code
a: ac, // Account Id
l: la, // Local
c: cId // Consumer Id
},
data: {
"ConsumerAggregatedAttributes": [
{
"ConsumerAggregatedAttributeID": 28,
"ConsumerID": "1159040334",
"ApplicationCode": "36363636",
"LocaleCode": null,
"AttributeCode": "FailedLoginAttemps",
"Value": "0",
"CreateTS": "2015-12-14 23:53:30.517",
"UpdateTS": "2015-12-15 01:12:06.947"
}
],
"ConsumerID": "1159040334",
"PersonalQRImageGUID": "a30d62db-0981-4b7c-bed0-4cf66d2fe1a3",
"PictureMediaGUID": null,
"Nickname": "testing",
"LastGPSCoordinate": null,
"TotalCredit": 0,
"AvailableCredit": 0,
"IsActive": true,
"IsPictureApproved": false,
"Firstname": "test",
"Lastname": "test",
"Username": "test.email@test.com.au",
"Password": null,
"Email": "test.email@test.com.au",
"Mobile": "04145588774",
"Address": null,
"City": null,
"Province": null,
"PostalCode": null,
"Country": null,
"DateOfBirth": null,
"Gender": null,
"Language": null,
"CreateTS": "2015-12-14 23:51:27.143",
"UpdateTS": "2015-12-15 01:17:22.567",
"ConsumerTypeCode": "Admin",
"DefaultLocaleCode": "EN",
"IsTestUser": false,
"Distance": null
}
}).success(function (data, status, headers, config) {
$scope.response = data;
}).error(function (data, status, headers, config) {
console.log(data);
$scope.response = data;
});
现在当我调用这个函数时,它应该像这样传递它:
https://someUrl.com/servicecol.svc/updateProfile?$expand=ConsumerAggregatedAttributes&LocationID=1&Role=Manager&IsProfileComplete=True
{
"ConsumerAggregatedAttributes": [{
"ConsumerAggregatedAttributeID": 28,
"ConsumerID": "1159040334",
"ApplicationCode": "36363636",
"LocaleCode": null,
"AttributeCode": "FailedLoginAttemps",
"Value": "0",
"CreateTS": "2015-12-14 23:53:30.517",
"UpdateTS": "2015-12-15 01:12:06.947"
}],
"ConsumerID": "1159040334",
"PersonalQRImageGUID": "a30d62db-0981-4b7c-bed0-4cf66d2fe1a3",
"PictureMediaGUID": null,
"Nickname": "testing",
"LastGPSCoordinate": null,
"TotalCredit": 0,
"AvailableCredit": 0,
"IsActive": true,
"IsPictureApproved": false,
"Firstname": "test",
"Lastname": "test",
"Username": "test.email@test.com.au",
"Password": null,
"Email": "test.email@test.com.au",
"Mobile": "04145588774",
"Address": null,
"City": null,
"Province": null,
"PostalCode": null,
"Country": null,
"DateOfBirth": null,
"Gender": null,
"Language": null,
"CreateTS": "2015-12-14 23:51:27.143",
"UpdateTS": "2015-12-15 01:17:22.567",
"ConsumerTypeCode": "Admin",
"DefaultLocaleCode": "EN",
"IsTestUser": false,
"Distance": null
}
但它却像这样传递它
https://someUrl.com/servicecol.svc/updateProfile?$expand=ConsumerAggregatedAttributes&LocationID=1&Role=Manager&IsProfileComplete=True**[object Object]**
正如您在 Url 末尾看到的那样,它有对象对象,经过我自己和拥有此 API 的人的调查后,这就是它失败的原因,任何人都可以阐明我如何获得它实际上正确发布而不是在 url 中有 [object object]?
【问题讨论】:
-
你在使用 AngularJS 吗?
-
嘿。感谢您的回复,是的,我是