I am trying to connect to a GET Web API controller using the $ http.get app in angular as follows:
$http.get(BasePath + '/api/documentapi/GetDocuments/' ,
{
params: {
PrimaryID: ID1,
AlternateID: ID2,
}
}).then( ...
In my case, the value of PrimaryID or AlternateID will matter. Thus, one of them will always be zero.
My web api method
public DocumentsDto[] GetDocuments(decimal? PrimaryID, decimal? AlternateID)
{ ...
When one of the values ββis null, the url generated by $ http.get looks like this:
http://BaseServerPath/api/documentapi/GetDocuments/?PrimaryID=1688
or
http://BaseServerPath/api/documentapi/GetDocuments/?AlternateID=154
This does not affect my Web API method.
However, if I use
http://BaseServerPath/api/documentapi/GetDocuments/?PrimaryID=1688&AlternateID=null
it works. I can hard set null values ββin my parameters, however I would like to know if there is any correct way to achieve this.
Thanks Sam
source
share