3
나는 현재 내가 나머지 기반 서비스는 다음 URL에서 설치 한 순간에 안드로이드를위한 모노 실험하고RestSharp 안드로이드에 대한 응답은
http://localhost:8080//api/mobileclient?email=aakpenyi3%40yahoo.com&phone=80604456789
서버는 IIS8.0과 서비스가를 포기하지 않을 asp.net 웹 API를 사용하여 작성되었습니다.
Curi 또는 Plugin 기반 Rest Client를 사용하여 요청할 때. 모두 잘하고 응답이
나 모바일 클라이언트에서 이것을 사용하려면 그러나을 예상대로 오는
I 안드로이드
에 대한public class RequestBrokerClass
{
const string baseUrl = "http://partnerens.com/api/mobileclient/";
public T Execute<T>(RestRequest request) where T : new()
{
var client = new RestClient();
client.BaseUrl = baseUrl;
var response = client.Execute<T> (request);
if (response.ErrorException != null) {
const string message = "Error contacting partnerens servers";
var exception = new ApplicationException (message, response.ErrorException);
throw exception;
}
return response.Data;
}
}
을 자 마린을 사용하여 다음 코드와 이상을 사용하여 다음 발췌가 암호. 이메일은 URL로 인코딩되었습니다.
public IEnumerable<PartnershipRecords> GetItemFromApi(string email, string phoneNumber)
{
var request = new RestRequest();
request.Method = Method.GET;
request.AddParameter ("email", email);
request.AddParameter ("phone", phoneNumber);
var items = new RequestBrokerClass().Execute<List<PartnershipRecords>> (request);
return items;
}
그러나 모바일 클라이언트를 사용하여 만든 경우 응답은 항상 비어 있지만 REST 클라이언트를 사용하여 만든 경우 비어 있지는 않습니다.
당신이 연결 문제를 배제 적이 추가? 'var response = new WebClient.DownloadString ("http : // localhost : 8080 // api/mobileclient? email = aakpenyi3 % 40yahoo.com & phone = 80604456789"); – SKall