Hello, i am quite new to web apis but following the "CRUD Operations with .NET DataStore" i was able to publish my first web api, created my own data context and successfully generated my first c# datastore model. Also created the controller to retrieve data and successfully accessed it from a pb application using RESTClient.
How cool is that? :)
Now my question is:
Having a datastore with a retrieval argument (i.e. date type) how do i call the method to retrieve data passing a parameter? What should i put in the URL?
this is what i did in the services interface
using PowerBuilder.Data;
namespace StartWebApi1.Services
{
public interface IDayFatService
{
IDataStore RetrieveByDate(string dataoggi);
}
}
and the service like this:
public IDataStore RetrieveByDate(string dataoggi)
{
var dss_DayFat = new DataStore("dss_dayfat", _context);
dss_DayFat.Retrieve(dataoggi);
return dss_DayFat;
}
in the controller:
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public ActionResult
{
IDataStore dss_DayFat = new DataStore("dss_dayfat");
try
{
dss_DayFat = _dayfatservice.RetrieveByDate(dataoggi);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
if (dss_DayFat.RowCount <= 0)
{
return NotFound("No rows retrieved.");
}
else
{
return Ok(dss_DayFat);
}
}
first of all i am not sure if i have to use a "string" type to define the parameter, but how do i build the url to call the api from pb?
inv_RestClient.sendgetrequest("http://xxx.xxx.xxx.xxx:82/api/dayfat/retrievebydate???????", ls_response)
any help would be appreciated
TIA,
simone