Friday 15 February 2013

xcode5 - JSON POST REQUEST USING AFNETWORKING XCODE -



xcode5 - JSON POST REQUEST USING AFNETWORKING XCODE -

i'm having problem , spend many hours finding solution problem posting json info our server. x-www-form-urlencoded think. when utilize postman google chrome plugin testing , post request working when applied app. server returns nil , think have error. post in postman.

access_token:myaccesstoken cartdata:[{"mapattributes":[{"name":"color","value":"yellow","price":"0","id":"b_14","isselected":1,"img_id":"1005"},{"name":"size","value":"xl","price":"100","id":"b_11","isselected":1,"img_id":"1005"},{"name":"material","value":"metal","price":"0.00","id":"b_13","isselected":1,"img_id":"1005"}],"quantity":"1","slug":"mi-3-16gb"}]

and request correct. when applied app.

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; nsdictionary *parameters = @{@"access_token":token,@"cartdata":mydata}; [manager post:@"http://192.168.4.30/myurl" parameters:parameters success:^(afhttprequestoperation *operation, id responseobject) { nslog(@"%@",responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"error: %@", error); }]

the value of mydata is:

[{"mapattributes":[{"name":"color","value":"yellow","price":"0","id":"b_14","isselected":1,"img_id":"1005"},{"name":"size","value":"xl","price":"100","id":"b_11","isselected":1,"img_id":"1005"},{"name":"material","value":"metal","price":"0.00","id":"b_13","isselected":1,"img_id":"1005"}],"quantity":"1","slug":"mi-3-16gb"}]

it returns () , not having error.

this homecoming when used postman.

{ "6e2713a6efee97bacb63e52c54f0ada0": { "rowid": "6e2713a6efee97bacb63e52c54f0ada0", "productid": 557, "productitemid": 1515, "maximumavailability": "2", "slug": "lg-optimus-g2-d802", "name": "lg optimus g2 d802", "quantity": "1", "description": "<h1 id=\"prod_title\">lg optimus g2 d802</h1>", "brand": "custom", "originalprice": "27690.0000", "finalprice": "18829.2", "sellerdetails": { "sellername": "lazada", "sellerrating": { "ratecount": 0, "ratedescription": { "item quality": 0, "communication": 0, "shipment time": 0 } }, "sellercontactnumber": "", "selleremail ": "ryanannatuvasquez2@easyshop.ph" }, "images": { "1004": "./assets/product/557_128_20140715/557_128_20140715722500.jpg" }, "mapattributes": [] } }

please help me code. thankyou.

just alter json boolean info string "true"

[{"mapattributes":[{"name":"color","value":"yellow","price":"0","id":"b_14","isselected":"true","img_id":"1005"},{"name":"size","value":"xl","price":"100","id":"b_11","isselected":"true","img_id":"1005"},{"name":"material","value":"metal","price":"0.00","id":"b_13","isselected":"true","img_id":"1005"}],"quantity":"1","slug":"lg-optimus-g2-d802"}] 2014-10-14 11:56:11.833 easyshop.ph[12399:1263983] [{"mapattributes":[{"name":"color","value":"yellow","price":"0","id":"b_14","isselected":"true","img_id":"1005"},{"name":"size","value":"xl","price":"100","id":"b_11","isselected":"true","img_id":"1005"},{"name":"material","value":"metal","price":"0.00","id":"b_13","isselected":"true","img_id":"1005"}],"quantity":"1","slug":"lg-optimus-g2-d802"}]

xcode5 http-post afnetworking-2

No comments:

Post a Comment