响应状态代码不表示成功:“ 400”(“错误请求”)

时间:2019-02-19 12:19:48

标签: android api refit

我想使用改装将数据发布到我的android xamarin应用程序中的API,我已经在Postman测试了API,并且工作正常,但是在android应用程序中我遇到了异常错误的请求,这是我添加接口的android代码我不知道是什么问题

public interface RequestAPI
{
    [Post("/request")]
    Task<create_request> submit([Body] create_request request);

}

  requestAPI= RestService.For<RequestAPI>("http://courier-magconsulting.azurewebsites.net/api");

        button.Click += async delegate
          {
              try
              {
                  create_request request = new create_request();
                  request.PickUpPhone = "7664554";
                  request.DownPayment = 89;
                  request.DeliveryFees = 56.8;
                  request.Note = "i need a help!";
                  request.RequestID = 88;   //  replace the value yourself 
                  request.DekiveryLocationLatitude = 2323;
                  request.DeliveryLocationLongitude = 232;
                  request.PickUpLocationLatitude = 898;
                  request.PickUpLocationLongitude = 1123;

                  BroadcastType type = new BroadcastType();
                  type.Name = "All";
                  type.ID = 60;      // replace the value yourself 
                  request.BroadcastType = type;

                  Cargosize size = new Cargosize();
                  size.Name = "Small";
                  size.ID = 1;      // replace the value yourself 
                  request.Cargosize = size;

                  Cargoweight weight = new Cargoweight();
                  weight.Name = "Large";
                  weight.ID = 2;      // replace the value yourself 
                  request.CargoWeight = weight;

                  Sender sender_ = new Sender();
                  sender_.Name = "Ahmad";
                  sender_.SenderID = 1;      // replace the value yourself 
                  sender_.Phone = "8788";
                  sender_.SocialID = "8787";
                  sender_.RatingAvg = 5;
                  SenderStatus status = new SenderStatus();
                  status.ID = 1;
                  status.Name = "Active";
                  sender_.Senderstatus = status;

                  request.Sender = sender_;

                  create_request result = await requestAPI.submit(request);

                  Toast.MakeText(this, "Request created", ToastLength.Long).Show();

              }

              catch(Exception ex)
              {
                  Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
              }
          };

0 个答案:

没有答案