meridianww / M4PLBase

0 stars 1 forks source link

BizMobl Dev - InsertJobGateway Returning 500 Error #478

Closed nmfujimoto closed 3 years ago

nmfujimoto commented 3 years ago

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.

nmfujimoto commented 3 years ago

image

image

nmfujimoto commented 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.

https://m4pl-dev.meridianww.com/M4PLAPI/API/Jobs/Gateway/InsertJobGateway?JobId=262845&&GatewayStatusCode=X5&&DeliveredDate=3/11/2021 12:00:00 AM

image

prashantaggarwal1999 commented 3 years ago

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();

nmfujimoto commented 3 years ago

@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.