0

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();
    }
2
  • 1
    We can't do anything with "no results" but guess. Please read How to Ask and include all relevant details. Commented Jul 31, 2017 at 14:16
  • I meant that it literally executes a query that I don't expect to get any kind of result from. Let me rephrase the paragraph. Commented Jul 31, 2017 at 14:19

1 Answer 1

3

You have marked ExportScrubList as private. You cannot call an action marked as private via http.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, this feels like a duh moment! haha Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.