I'm building an app for the iPhone linking to a Delphi XE2 DataSnap REST server.
Originally I was coding the iOS front-end with the help of Embarcadero's mobile connectors, however due to many bugs I'm having to write my own link with the help of asihttprequest.
Whilst I can get the system to handle JSON requests and pass one or two parameters (using the URL) such as: -
NSURL *theURL = [NSURL URLWithString:@"http://192.168.1.2:8080/datasnap/rest/tservermethods1/SaveMileage/type1/100];
request = [ASIHTTPRequest requestWithURL:theURL];
(where the server method is SaveMileage and the two parameter values are type1 and 100)
However if I want to add more complex parameters I've needed to use appendPostData to post the parameters using JSON: -
[request appendPostData:jsonMutData];
Below is the output of the jsonMutData: -
{
"client_ref" : "ABC100",
"mileage_type" : "Fee Work",
"mileage_description" : "test",
"mileage_id" : "0",
"mileage_date" : "03\/15\/2012"
}
However when I post this to my server via the app I get the the following response back and the call isn't handled by the DataSnap server: -
{"error":"**Cannot convert JSON value** {\"client_ref\":\"ABC100",\"mileage_type\":\"Fee Work\",\"mileage_description\":\"test\",\"mileage_id\":\"\",\"mileage_date\":\"03\/15\/2012\"} input into TDBXTypes.WideString"}
Below is the structure of the DataSnap function: -
function TServerMethods1.updateSaveMileage(mileage_id: string;
client_ref: string; mileage_date: String; mileage_type: string;
mileagefigure: string; description: string; notepad: string): string;
Any ideas on how to resolve this?