I'm trying to post a data from a Web Api to another Web Api in different project solution with a controller like this
public class PublishWebController : ApiController
{
static HttpClient client = new HttpClient();
static async Task<Uri> CreateArticleAsync(Article article)
{
HttpResponseMessage response = await client.PostAsJsonAsync("api/articles", article);
response.EnsureSuccessStatusCode();
// return URI of the created resource.
return response.Headers.Location;
}
void Main()
{
Post().GetAwaiter().GetResult();
}
//POST api/<controller>
[Mime]
public async Task<Article> Post()
{
client.BaseAddress = new Uri("http://localhost:64395/api/");
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var fileuploadPath = HttpContext.Current.Server.MapPath("~/uploads");
var multiFormDataStreamProvider = new MultiFileUploadProvider(fileuploadPath);
await Request.Content.ReadAsMultipartAsync(multiFormDataStreamProvider);
string uploadingFileName = multiFormDataStreamProvider.FileData.Select(x => x.LocalFileName).FirstOrDefault();
return new Article
{
Title = HttpContext.Current.Request.Form["Title"],
ArticleContent = HttpContext.Current.Request.Form["ArticleContent"],
ImagePath = "~/Images/" + Path.GetFileName(uploadingFileName),
};
}
}
When I tried sending a data with Postman, it returned a value to its localhost but nothing to the uri that I targeted
How do I fix this problem?

