您好我必须使用REST API将我的记录更新到服务器。 我正在使用AFNetworking Library并形成PUT请求参数格式,如下所示
{
"type":"goal",
"field_weight_goal": {
"und": [
{
"value": "60"
}
]
},
"field_weight_actual": {
"und": [
{
"value": "90"
}
]
},
"field_weight_date": {
"und": [
{
"value": "05-10-2017",
"format": null,
"safe_value": "05-10-2017"
}
]
}
}
以下是我的代码。
NSDictionary *params = @{@"type": @"goal",
@"field_weight_goal" : @{@"und": @[ @{@"value": self.goalWeightTextField.text } ] },
@"field_weight_actual" : @{@"und": @[ @{@"value": self.currentWeightTextField.text } ] },
@"field_weight_date" : @{@"und": @[ @{@"value": currentDate, @"format" : [NSNull null] , @"safe_value" : currentDate } ] }
};
该值未在服务器中更新,我收到错误...请求失败:不可接受(406)。请帮我纠正我的字典格式。 在xcode中调试我的参数格式如下
{
"field_weight_actual" = {
und = (
{
value = "100.0";
}
);
};
"field_weight_date" = {
und = (
{
format = "<null>";
"safe_value" = "04-18-2017";
value = "04-18-2017";
}
);
};
"field_weight_goal" = {
und = (
{
value = "90.0";
}
);
};
type = goal;
}