Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

CommitAsync method returns error 415 #1

@paulofoxbr

Description

@paulofoxbr

CommitAsync return error 415. Solution is set a ContentType Media.

The rewritten method below:

    public async Task CommitAsync(IEnumerable<string> handles, CancellationToken cancellationToken)
    {
        var path = "api/orders/feed";
        var contentString = JsonSerializer.Serialize(new { handles });

         var request = new HttpRequestMessage(HttpMethod.Post, path)
        {
            Content = new StringContent(contentString)
            { 
                Headers = 
                {
                    ContentType =  new MediaTypeHeaderValue("application/json") // new
                }
            }
        };

        request.Headers.Add("Accept", "application/json"); // new
        request.Headers.Add("X-VTEX-API-AppKey", _appKey);
        request.Headers.Add("X-VTEX-API-AppToken", _appToken);

        

        var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
        if (!response.IsSuccessStatusCode) throw new Exception($"Unable to execute POST in the path `{path}`, the status code was `{response.StatusCode}`");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions