Form dictionary as a parameter in PUT API request - AFNetworking

64 views Asked by At

Hi I have to update my records to the server using REST API. I'm using AFNetworking Library and forming the PUT request parameter format as below

{
"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"
          }
        ]
      }
}

Below is my code.

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 } ] }
                                 };

The value is not updating in the server and I'm getting error ... Request failed: unacceptable (406). Please help me to correct my dictionary format. while debugging in xcode my parameter format as below

 {
    "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;
}
0

There are 0 answers