Question concerning REST API functionality

I have several API functions which pass a request body in the call. I created it and then used the Send button to Access the API Call. It returns an Unsupported Media Error: {
"type": "RFC 9110 - HTTP Semantics",
"title": "Unsupported Media Type",
"status": 415,
"traceId": "00-7bb533678789a75a92db56cae2121947-8755b18c76644962-00"
}. I have never seen this error before. When I use POSTMAN to send the request it returns successfully. Any Ideas as to why this is so?

How? What is the expected body and what did you provide?

This is what your Code Generator Created:
partial void OnPostUspsSearchDomesticBaseRates(HttpRequestMessage request);
partial void OnPostUspsSearchDomesticBaseRatesResponse(HttpResponseMessage response);

    public async Task PostUspsSearchDomesticBaseRates(string request)
    {
        var uri = new Uri(httpClient.BaseAddress, $"api/v3/RateCalculator/postUspsSearchDomesticBaseRates");

        var request = new HttpRequestMessage(HttpMethod.Post, uri);
        request.Content = JsonContent.Create<string>(request);

        OnPostUspsSearchDomesticBaseRates(request);

        await AuthorizeRequest(request);

        var response = await httpClient.SendAsync(request);

        response.EnsureSuccessStatusCode();

        OnPostUspsSearchDomesticBaseRatesResponse(response);
    }

and this is what it should be:

/// <summary>
/// Called when [post usps search domestic base rates].
/// </summary>
/// <param name="request">The request.</param>
partial void OnPostUspsSearchDomesticBaseRates(HttpRequestMessage request);

/// <summary>
/// Called when [post usps search domestic base rates response].
/// </summary>
/// <param name="response">The response.</param>
partial void OnPostUspsSearchDomesticBaseRatesResponse(HttpResponseMessage response);

/// <summary>
/// Called when [post usps search domestic base rates].
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Nullable&lt;PostUspsSearchDomesticBaseRatesResponse&gt;.</returns>
public async Task<PostUspsSearchDomesticBaseRatesResponse?> PostUspsSearchDomesticBaseRates(
VisionSuiteShipManager.Server.Models.VisionSuiteCoreApi.PostUspsSearchDomesticBaseRatesRequest request)
{
    if (httpClient.BaseAddress == null) return null;
    var uri = new Uri(httpClient.BaseAddress, $"api/v3/RateCalculator/postUspsSearchDomesticBaseRates");

    var httpRequest = new HttpRequestMessage(HttpMethod.Post, uri);
    httpRequest.Content = JsonContent.Create(request);

    OnPostUspsSearchDomesticBaseRates(httpRequest);

    await AuthorizeRequest(httpRequest);

    var response = await httpClient.SendAsync(httpRequest);

    response.EnsureSuccessStatusCode();

    OnPostUspsSearchDomesticBaseRatesResponse(response);

    return await response.Content
        .ReadFromJsonAsync<
            VisionSuiteShipManager.Server.Models.VisionSuiteCoreApi.PostUspsSearchDomesticBaseRatesResponse>()
        .ConfigureAwait(false);
}

The JSON Request BODY should be (NOTE: Account number is FAKE):
{
"originZIPCode": "94538",
"destinationZIPCode": "47905",
"weight": 7.2,
"length": 25,
"width": 8.25,
"height": 8.625,
"mailClass": "USPS_GROUND_ADVANTAGE",
"processingCategory": "NON_MACHINABLE",
"destinationEntryFacilityType": "NONE",
"rateIndicator": "DR",
"priceType": "COMMERCIAL",
"mailingDate": "2023-12-28",
"accountType": "EPS",
"accountNumber": "1111111111"
}

The JSON Response should have been:
{
"totalBasePrice": 23.82,
"rates": [
{
"SKU": "DUXR0XXXXC08110",
"description": "USPS Ground Advantage Nonmachinable Dimensional Rectangular",
"priceType": "COMMERCIAL",
"price": 19.82,
"weight": 7.2,
"dimWeight": 11,
"fees": [
{
"name": "Nonstandard Length > 22",
"SKU": "D811XUXXXXX0000",
"price": 4
}
],
"startDate": "2023-07-09",
"endDate": "2024-01-20",
"warnings": [
{
"warningCode": "001",
"warningDescription": "NSA rate not found for request. Published rate returned."
}
],
"mailClass": "USPS_GROUND_ADVANTAGE",
"zone": "08"
}
]
}

Hi @FastTrak,

How does the method configuration look like in RBS? The parameter type seems to be set to string when it should be something else.

RBS sets it as a string as it does not show a suitable parameter type in the
dropdown. I was required to create the method with parameters manually.

You can type your own type in that dropdown.

I have recorded a short video showing how to send Body parameters in JSON format. It uses the JSONPlaceholder API.

post-body