Closed Manthan2611 closed 5 years ago
There is no change to the code base since Feb 2018. No recent changes.
The only casting I see is the last line.
Case cres = (Case)response.Data;
May be you remove the cast and check for an object to see what is returned. Been a while I worked on this, and I may not be able to figure it out that quickly.
Try this and see why the cast is failing:
object cres = response.Data;
Also ensure you are using relevant SugarCrm version.
Hello,
Regrets for late reply. The following is the response i am getting in the object
3d708bde-a071-1fca-b8d3-5bf8e3a33bc0
I'm using the sugarcrm community edition 6.5
Does not look right to me.
Please try see what the raw request and response is.
response.JsonRawRequest response.JsonRawResponse
Again Regrets for the delayed response
Below are the JsonRawRequest:
{"resource":"","parameters":[{"name":"method","value":"set_entry","type":"GetOrPost"},{"name":"input_type","value":"json","type":"GetOrPost"},{"name":"response_type","value":"json","type":"GetOrPost"},{"name":"rest_data","value":"{\"session\":\"8j8erj7tvr2qlj2bu0knuftni7\",\"module_name\":\"Cases\",\"name_value_list\":{\"name\":{\"name\":\"name\",\"value\":\"API Testing\"},\"description\":{\"name\":\"description\",\"value\":\"This is where i am going to write my tally problem\"},\"status\":{\"name\":\"status\",\"value\":\"New\"},\"priority\":{\"name\":\"priority\",\"value\":\"P2\"},\"account_id\":{\"name\":\"account_id\",\"value\":\"b8301ff8-9157-3144-2385-5aa25420ac0f\"},\"enjay_mobile_c\":{\"name\":\"enjay_mobile_c\",\"value\":\"9029171999\"},\"enjay_emailid_c\":{\"name\":\"enjay_emailid_c\",\"value\":\"manthan@cbditsolutions.com\"},\"enjay_case_source_c\":{\"name\":\"enjay_case_source_c\",\"value\":\"Tally\"},\"enjay_support_mode_c\":{\"name\":\"enjay_support_mode_c\",\"value\":\"call\"},\"assigned_user_name\":{\"name\":\"assigned_user_name\",\"value\":\"8dac4928-7275-1442-0f18-5abe0774348b\"}}}","type":"GetOrPost"},{"name":"Accept","value":"application/json, application/xml, text/json, text/x-json, text/javascript, text/xml","type":"HttpHeader"}],"method":"POST","uri":"https://srk.njcrm.in/service/v4_1/rest.php"}
Below are then JsonRawResponse:
{"statusCode":200,"content":"{\"id\":\"242c099d-c736-279a-5f93-5c0265a489ab\",\"entry_list\":{\"assigned_user_name\":{\"name\":\"assigned_user_name\",\"value\":\"8dac4928-7275-1442-0f18-5abe0774348b\"},\"name\":{\"name\":\"name\",\"value\":\"API Testing\"},\"description\":{\"name\":\"description\",\"value\":\"This is where i am going to write my tally problem\"},\"status\":{\"name\":\"status\",\"value\":\"New\"},\"priority\":{\"name\":\"priority\",\"value\":\"P2\"},\"account_id\":{\"name\":\"account_id\",\"value\":\"b8301ff8-9157-3144-2385-5aa25420ac0f\"},\"enjay_mobile_c\":{\"name\":\"enjay_mobile_c\",\"value\":\"9029171999\"},\"enjay_emailid_c\":{\"name\":\"enjay_emailid_c\",\"value\":\"manthan@cbditsolutions.com\"},\"enjay_case_source_c\":{\"name\":\"enjay_case_source_c\",\"value\":\"Tally\"},\"enjay_support_mode_c\":{\"name\":\"enjay_support_mode_c\",\"value\":\"call\"}}}","headers":[{"Name":"Pragma","Value":"no-cache","Type":3,"ContentType":null},{"Name":"Content-Length","Value":"753","Type":3,"ContentType":null},{"Name":"Cache-Control","Value":"no-store, no-cache, must-revalidate, post-check=0, pre-check=0","Type":3,"ContentType":null},{"Name":"Content-Type","Value":"application/json; charset=UTF-8","Type":3,"ContentType":null},{"Name":"Date","Value":"Sat, 01 Dec 2018 10:44:09 GMT","Type":3,"ContentType":null},{"Name":"Expires","Value":"Thu, 19 Nov 1981 08:52:00 GMT","Type":3,"ContentType":null},{"Name":"Set-Cookie","Value":"PHPSESSID=8j8erj7tvr2qlj2bu0knuftni7; path=/","Type":3,"ContentType":null},{"Name":"Server","Value":"Apache/2.4.7 (Ubuntu)","Type":3,"ContentType":null},{"Name":"X-Powered-By","Value":"PHP/5.5.9-1ubuntu4.26","Type":3,"ContentType":null}],"responseUri":"https://srk.njcrm.in/service/v4_1/rest.php","errorMessage":null}
Front end:
I've also passed owner (assign to) value but it is not getting saved.
So I can see you are not getting an error and also looks like reasonable data coming back
"statusCode":200,"content":"{\"id\":\"242c099d-c736-279a-5f93-5c0265a489ab\",\"entry_list\":
So I will suggest that as the usual cast does not work, that you find a way to parse the raw Json response.
Also looking at the original request, the response you get is actually correct. You are requesting to create a model (var request = new SugarRestRequest(moduleName, RequestType.Create);) and the response of the creation is the id of the created model object (3d708bde-a071-1fca-b8d3-5bf8e3a33bc0).
Sorry I misled you with my earlier statement as I missed the "Create" part.
Just more info. Since you are creating you should only cast to string. Please see wiki https://github.com/mattkol/SugarRestSharp/wiki/Create-Module
Sure will i.
As you can see in my above image i am passing the assigned user value but i am not able to received that value in front end.
Previously before opening the ticket i used to get cast json response. i was using the same for around 6-8 months and it suddenly stop working.
Thank you for your help ;)
Hi,
I am getting the following error
While the code behind is ` string moduleName = "Cases";
few weeks back it was working fine but from now i am getting the cast exception.