whenver submit the Url through postman i wnat to get the Distributorslist.
Error details :--
The server couldn't send a response: Ensure that the backend is working properly
Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly :Ensure that proxy is configured correctly in Settings > Proxy
Request timeout: Change request timeout in Settings > General
1.PurchaseOrderController.cs
[HttpGet]
[Route("GetAllDistributors/")]
[ResponseType(typeof(string))]
public HttpResponseMessage GetAllDistributors()
{
var response = _poService.GetAllDistributorsOp();
HttpResponseMessage httpResponse = null;
if (response.Count == 0)
{
httpResponse = Request.CreateResponse(HttpStatusCode.NotFound, "No data found");
return httpResponse;
}
else if (response == null)
{
httpResponse = Request.CreateResponse(HttpStatusCode.BadRequest, response);
return httpResponse;
}
return Request.CreateResponse(HttpStatusCode.OK, response);
}
2.PurchaseOrderServices.cs:--
using QFT_POMS_SVC.Domain.POMS;
using System.Collections.Generic;
using System.Linq;
namespace QFT_POMS_SVC.Services.POMS
{
public class PurchaseOrderService : IPurchaseOrderService
{
// ProductStatusEntities entities = new ProductStatusEntities();
private DBMapper _dbContext;
private Result _result;
private object query_poms;
public PurchaseOrderService()
{
_dbContext = new DBMapper();
_result = new Result();
}
public IList<Distributor> GetAllDistributorsOp()
{
var query = from d in _dbContext.DistributorRepository select d;
return query.ToList();
}
public IList<PurchaseOrder> GetAllPOByDistributorIdOp(int DistributorId)
{
var query = from po in _dbContext.PurchaseOrderRepository
where po.DistributorId == DistributorId
select po;
return query.ToList();
}
public PurchaseOrder GetPODetailsOp(int PurchaseOrderId)
{
var query = from po in _dbContext.PurchaseOrderRepository
where po.Id == PurchaseOrderId
select po;
return query.First();
}
private void UpdatePurchaseOrderItems(int purchaseorderid, List<PurchaseOrderItem> items)
{
foreach (var item in items)
{
var _item = _dbContext.PurchaseOrderItemsRepository.Where(po => po.Id == item.Id).First();
_item.QtyReceived = item.QtyReceived;
_item.Received = item.Received;
_item.UnitCostReceived = item.UnitCostReceived;
_item.Discontinued = item.Discontinued;
}
_dbContext.SaveChanges();
}
public Result UpdatePurchaseOrderOp(PurchaseOrder po)
{
var _purchaseOrder = GetPODetailsOp(po.Id);
_purchaseOrder.deleted = po.deleted;
_purchaseOrder.InvoiceDate = po.InvoiceDate;
_purchaseOrder.InvoiceDueDate = po.InvoiceDueDate;
_purchaseOrder.InvoiceNumber = po.InvoiceNumber;
//_purchaseOrder.items.Clear();
//_purchaseOrder.items = po.items;
_purchaseOrder.PORcvdAmount = po.PORcvdAmount;
UpdatePurchaseOrderItems(po.Id, po.items);
_dbContext.SaveChanges();
return _result;
}
/*Method Added by Complitsol , TO generate Purchase Order based on Distributorid */
public int GeneratePurchaseOrderid(int distributorid)
{
// To generate new PO number
var query_genpo = "";
int month = System.DateTime.Now.Month;
if (month > 9)
{
query_genpo = distributorid.ToString() + System.DateTime.Now.Month + System.DateTime.Now.Day + System.DateTime.Now.Year + System.DateTime.Now.Hour + System.DateTime.Now.Minute;
}
else
{
query_genpo = distributorid.ToString() + '0' + System.DateTime.Now.Month + System.DateTime.Now.Day + System.DateTime.Now.Year + System.DateTime.Now.Hour + System.DateTime.Now.Minute;
}
// To fetch number of order quantity and total quantity for each product based on particual distributor id
var query_poms = @"select orditem.productid,p.name as productname,dpm.Unitprice,
did.name as Distributorname,
sum(orditem.quantity) as orderquantity,
sum(pwi.Stockquantity+p.Stockquantity - pwi.ReservedQuantity) as TotalQuantity
from orderitem orditem, [order] ord, product p, distributor did,
distributorproductmapping dpm,
productwarehouseinventory pwi
where ord.id = orditem.orderid
and p.producttypeid = orditem.productid
and dpm.distributorid = " + distributorid +
@" and dpm.distributorid = did.id
and dpm.productid = pwi.productid
and dpm.productid = orditem.productid
and ord.orderstatusid = 20
and p.producttypeid <> 5
group by orditem.productid, p.name, p.producttypeid,
did.name, dpm.Stockstatus, dpm.Unitprice,
pwi.Stockquantity, p.Stockquantity";
var result1 = _dbContext.Database.SqlQuery<string>(query_poms).ToArray();
int flag = 0;
int Purchaseorderid = 0;
for (int index = 0; index < result1.Length; index++)
{
if (int.Parse(result1[index][5].ToString()) - int.Parse(result1[index][4].ToString()) < 0)
{
if (flag == 0)
{
// Insert newly generated PO number into Purchase order table
var query_insPO = "Insert into Purchaseorder(PONumber,DistributorId,deleted,InvoiceNumber,InvoiceDate,InvoiceDueDate,PORaisedAmount,PORcvdAmount) Select" + query_genpo + ", " + distributorid + " ,0,'0',getdate(),getdate(),0.00,0.00";
// where item insertion into PurchaseOrder table.
_dbContext.Database.ExecuteSqlCommand(query_insPO);
//To fetch the newly generated PO number's Id (Purchaseorderid) from Purchaseorder table
var query_getPoid = "Select Id from PurchaseOrder where PONUmber = " + query_genpo;
Purchaseorderid = int.Parse(_dbContext.Database.SqlQuery<string>(query_getPoid).ToString());
flag = 1;
}
if (flag == 1)
{
// Insert new PurchaseOrder details into PurchaseOrderItem table
var query_InsPORD = @"Insert into PurchaseOrderItem(Purchaseorderid,DistributorProductid,QtyOrdered,QtyReceived,UnitCostOrdered,
UnitCostReceived,Received,Discontinued) select" + Purchaseorderid +
@"," + int.Parse(result1[index][0].ToString()) +
@"," + int.Parse(result1[index][4].ToString()) +
@",0," + decimal.Parse(result1[index][3].ToString()) +
@"0,0,0";
// where the insertion into Purchaseorderitem table
_dbContext.Database.ExecuteSqlCommand(query_InsPORD);
}
}
}
return Purchaseorderid;
}
/* End of the code GeneratePO*/
}
}
Thank you
The server couldn't send a response: Ensure that the backend is working properly
Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly :Ensure that proxy is configured correctly in Settings > Proxy
whenver submit the Url through postman i wnat to get the Distributorslist.
Error details :--
The server couldn't send a response: Ensure that the backend is working properly
Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly :Ensure that proxy is configured correctly in Settings > Proxy
Request timeout: Change request timeout in Settings > General
Normally, this error means the web api doesn't work well, the postman couldn't get any response from the server.
Could you please tell me how you run the web API application? From the visual studio or the IIS?
You should make sure your web application has worked well.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
2 Posts
how to test my web Api by using postman tool can you please help me
Jul 02, 2019 06:07 AM|Kondalrao|LINK
Here I place my URL :--- and error details
URL:-http://localhost:52211/POMS/GetAllDistributors
whenver submit the Url through postman i wnat to get the Distributorslist.
The server couldn't send a response: Ensure that the backend is working properly
Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly :Ensure that proxy is configured correctly in Settings > Proxy
Request timeout: Change request timeout in Settings > General
All-Star
52793 Points
9695 Posts
MVP
Re: how to test my web Api by using postman tool can you please help me
Jul 03, 2019 12:00 AM|Ruchira|LINK
Can you try this:
https://stackoverflow.com/questions/47806876/could-not-get-any-response-response-when-using-postman-with-subdomain
Please 'Mark as Answer' if this post helps you
My Tech BlogStar
9831 Points
3120 Posts
Re: how to test my web Api by using postman tool can you please help me
Jul 03, 2019 05:24 AM|Brando ZWZ|LINK
Hi Kondalrao,
Normally, this error means the web api doesn't work well, the postman couldn't get any response from the server.
Could you please tell me how you run the web API application? From the visual studio or the IIS?
You should make sure your web application has worked well.
Best Regards,
Brando