Datasource RestApi doesn't allow multiple Body parameters

When connecting to a Rest API Data source I try to setup a Create Endpoint which needs multiple Body parameters, but I can only create one. Do I something wrong? In the docs there are only GET requests without the need of Body parameters.


RBS version 1.15.3

There can indeed be only one body parameter. You can specify it as a class with the required properties (hostname and the rest). Then pick it from the Type dropdown.

Here is how:

  1. Add a class to your Models directory e.g. ClientData.
  2. Add the properties:
  3. Use the full class name for the type of the body parameter (you have to type it in).

Thanks, didn't think about that.
But how can I execute the Send now? It only shows me one input box and it seems, that without sending it, it doesn't have the response model and the Service Method is incorrect.


The request model for the body:

using System;

namespace SharedKernel.Clients.Dtos;

public sealed record ClientForCreationDto
{
    public string Hostname { get; set; }
    public string MadeInOverride { get; set; }
    public string ShortNameOverride { get; set; }
    public DateTime LastConnectedOn { get; set; }

}

The generated method without executing the Send:

        public async Task CreateClient(SharedKernel.Clients.Dtos.ClientForCreationDto clientForCreationDto)
        {
            var uri = new Uri(httpClient.BaseAddress, $"clients");

            var request = new HttpRequestMessage(HttpMethod.Post, uri);
            request.Content = JsonContent.Create<SharedKernel.Clients.Dtos.ClientForCreationDto>(clientForCreationDto);

            OnCreateClient(request);

            var response = await httpClient.SendAsync(request);

            response.EnsureSuccessStatusCode();

            OnCreateClientResponse(response);
        }

Shouldn't the Enter Parameter Values Window not show all the prperties that needs to be added for the specified model? Or do I need to write it in a special format into the input box?

Thanks

This isn't implemented at the moment.

We will allow JSON input in this input box with the next release.

You can also try modifying the code of the generated method to return the required result. Change the return type and parse the response:


public async Task<Client> CreateClient(SharedKernel.Clients.Dtos.ClientForCreationDto clientForCreationDto)
        {
            var uri = new Uri(httpClient.BaseAddress, $"clients");

            var request = new HttpRequestMessage(HttpMethod.Post, uri);
            request.Content = JsonContent.Create<SharedKernel.Clients.Dtos.ClientForCreationDto>(clientForCreationDto);

            OnCreateClient(request);

            var response = await httpClient.SendAsync(request);

            response.EnsureSuccessStatusCode();

            OnCreateClientResponse(response);

            return await response.Content.ReadFromJsonAsync<Client>();
        }