PrestaSharp
PrestaSharp copied to clipboard
Supplier Orders
Hi,
I am trying to pull a list of supplier orders from PrestaShop, based on the date_add field. When I make the query, I get an error. Is this field filterable? Here is my URL:
https://xx.com/api/supply_orders?display=full&filter[date_add]=[2017-01-01 00:00:00,2017-01-31 00:00:00]&sort=id_DESC
This URL works:
https://xx.com/api/supply_orders/1
It also needs this: request.AddParameter("date", "1"); Probably you have to add it on the link too (...orders/&date=1....)
This code worked:
public List<Entities.supply_order> GetOrdersByDateRange(DateTime beginDate, DateTime endDate) { Dictionary<string, string> dtn = new Dictionary<string, string>(); //dtn.Add("date_add", MakeBrackets(beginDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd")) + "&date=1"); //RestRequest request = this.RequestForFilter("supply_orders", "full", dtn, null, null, "supply_orders"); var uri = String.Format("/supply_orders?display=full&filter[date_add]=>{0}&date=1", MakeBrackets(beginDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"))); var request = new RestRequest(uri, Method.GET); return this.ExecuteForFilter<List<Entities.supply_order>>(request); }