Closed nmfujimoto closed 3 years ago
@prashantaggarwal1999 I am using the update call on the .92 server. Using Swagger the call is successful but not in the code. I tried the DeliveredDate as a string and DateTime but neither worked.
Hi @nmfujimoto This is a Post API call now, you have to pass the data into a model.
public class BizMoblGatewayRequest
{
public long JobId { get; set; }
public string GatewayStatusCode { get; set; }
public DateTime? DeliveredDate { get; set; }
}
Please use the below code:
BizMoblGatewayRequest bizMoblGatewayRequest = new BizMoblGatewayRequest() { JobId = JobId, GatewayStatusCode = GatewayStatusCode, DeliveredDate = DeliveredDate }; string bizMoblGatewayRequestJson = string.Empty; string authToken = Authentication.TokenHelper.GetAuthToken(); string serviceCall = string.Format("{0}/Jobs/Gateway/InsertJobGateway", ConfigurationManager.AppSettings["APIUrl"]); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceCall); request.KeepAlive = false; request.ContentType = "application/json"; request.Method = "POST"; request.Headers.Add(HttpRequestHeader.Authorization, authToken); using (var streamWriter = new StreamWriter(request.GetRequestStream())) { bizMoblGatewayRequestJson = JsonConvert.SerializeObject(bizMoblGatewayRequest); streamWriter.WritebizMoblGatewayRequestJson); } WebResponse response = request.GetResponse();
@prashantaggarwal1999 The changes work! Question, will the StatusCode in the WebResponse always be "OK" even when the call fails? I tried the call using 0 as the Job Id and the StatusCode was "OK". I would like to return a boolean value indicating the call was successful or not when inserting the gateway.
The InsertJobGateway call is successful in updating the job's delivery date actual and adding the gateway to the job, but the API response is 500 Failure.