I'm having trouble with some code, and I just can't seem to figure this out. I am attempting to send some data to a backend API that connects to our SQL Server and executes a query that I don't expect any kind of results from. The problem I'm having is that the SQL command isn't being sent to the server, and I'm getting a "404 - This file doesn't exist".
Here is the front part of the request:
public async Task ExportNewLists (string pid, string list)
{
var endpointUrl = string.Concat(baseEndpoint, "ExportLists", "/", pid, "/", list);
AddAuthorization();
using (HttpResponseMessage response = await client.GetAsync(endpointUrl))
{
if (!response.IsSuccessStatusCode)
{
Response.StatusCode = (int)response.StatusCode;
var result = response.Content.ReadAsStringAsync().Result;
var message = JsonConvert.DeserializeObject<ResponseError>(result);
}
}
}
And here is the API function I'm trying to call:
[Route("api/Lists/ExportLists/{pid}/{list}")]
[HttpGet]
[ResponseType(typeof(void))]
private async Task<IHttpActionResult> ExportList(string pid, string list)
{
using (var connection = db.Database.Connection)
{
try
{
connection.Open();
var command = connection.CreateCommand();
command.Connection = connection;
command.CommandText = "EXEC LIST_EXPORT_SINGLE";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@PID");
command.Parameters["@PID"].Value = pid;
command.Parameters.Add("@LIST");
command.Parameters["@LIST"].Value = list;
await command.ExecuteNonQueryAsync();
connection.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return Ok();
}
You have marked ExportScrubList as private. You cannot call an action marked as private via http.