i'm trying use restsharp connect server. http error 406 not acceptable
. here web service response:
{"metainfo":{"errorstring":" ","errorcode":" ","result":true},"usermodel": {"userid":"123qwe","username":"aaa","firstname":"ali","lastname":"tbt"}}
the rest service simple php file created test:
<?php $a = array("metainfo"=>array("errorstring"=>" ","errorcode"=>" ","result"=>true),"usermodel"=>array("userid"=>"123qwe","username"=>"aaa","firstname"=>"ali","lastname"=>"tbt")); echo json_encode($a); ?>
and here registerresult , metainfo classes:
public class registerresult { public metainfo metainfo { get; set; } } public class metainfo { public string errorstring { get; set; } public string errorcode { get; set; } public bool result { get; set; } }
the code runs rest request follows:
var client = new restclient(configuration.portaluri); var request = new restrequest(requesturi, httpmethod.post); var asynchandle = await client.execute<registerresult>(request);
could please tell me problem is? i think wrong headers or encoding or that. right?
this error specific way programmers have created service calling. there's nothing wrong code c# perspective, way service author has chosen implement service doesn't in service call. have refer documentation or ask 1 of programmers.
here's explanation of http error 406 (taken http://www.checkupdown.com/status/e406.html):
fixing 406 errors - general
this error occurs infrequently in web browsers, because browsers accept data returned web server.
if client not web browser, can investigate problem looking @ accept headers generated client system
consider these headers modify:
•accept: mime types accepted client. example, browser may accept types of data (html files, gif files etc.) knows how process.
•accept-charset: character sets accepted client.
•accept-encoding: data encoding accepted client e.g. file formats understands. •accept-language: natural languages (english, german etc.) accepted client. •accept-ranges: whether client accepts ranges of bytes resource i.e. portion of resource.
for example, may need add request:
request.addheader("accept", "application/json");
Comments
Post a Comment