Home > other >  I'm not able to save images on the blog through API
I'm not able to save images on the blog through API

Time:03-22

I created an api in ASP.NET Core to save images in the azure blob, but for some reason when I make the request it's giving error 500

error 500

private async Task<string> Salvar(BlobStorageModel blobStorageModel)
    {
        var request = new HttpRequestMessage(HttpMethod.Post, $"{_blobStorageApiUrl}/api/BlobsStorages")
        {
            Content = new StringContent(JsonConvert.SerializeObject(blobStorageModel), Encoding.UTF8, "application/json")
        };

        var response = _httpClient.SendAsync(request).GetAwaiter().GetResult();
        string retorno = await response.Content.ReadAsStringAsync();

        if (response.IsSuccessStatusCode)
        {
            return JsonConvert.DeserializeObject<string>(retorno);
        }
        else
        {
            throw new Exception("");
          
        }
    }

I configured on azure to accept https over TLS/SSL

CodePudding user response:

The 500 error is from your api-tijoforte site, not yours.

If you have permission, you can show us the code about api/BlobsStorages, 500 error seems there are some code issue.

If you don't have permisson to check, you need to contact the site owner, let them help you check the logs and show the correct way to use this method.

And we suggest you use postman tool to test the api interface first, then you can write it in your code.

  • Related