HttpAPI Receive parameters with ComplexType

This example was created with a person class that is required to receive as a parameter

[Service]
public class SI_Module :Service
{

    [ApiMethod(HttpApiPath = "convertII/{value}", HttpApiMethod = ApiRequestMethod.Post)]
    public Persona ConvertToString(int value, [ApiQueryParameter] Persona Item)
    {
        return Item;
    }

}

[ObfuscationAttribute(Exclude = true)]
[Serializable]
public class Persona : RemObjects.SDK.Types.ComplexType
{
    [RemObjects.SDK.StreamAs(RemObjects.SDK.StreamingFormat.AnsiString)]
    public string lName { get; set; }
    [RemObjects.SDK.StreamAs(RemObjects.SDK.StreamingFormat.AnsiString)]
    public string fName { get; set; }
    [RemObjects.SDK.StreamAs(RemObjects.SDK.StreamingFormat.AnsiString)]
    public string userID { get; set; }
}

The API is generated correctly, but variable value Item is received in null the server.

Using http://editor2.swagger.io/#!/

Hello

Please take a look at https://docs.remotingsdk.com/Servers/Concepts/HttpAPI/NET/

Only parameters of string, number, boolean, enumeration type can be sent via the Url query string.

You have to remove the [ApiQueryParameter] attribute. After that the API method will work as expected:

Also have to mention that Swagger has issues atm with accessing non-https servers, at least in Chrome:

Mixed Content: The page at ‘https://editor.swagger.io//?_ga=XXXXXXXXXXXXXXX#/’ was loaded over HTTPS, but requested an insecure resource ‘http://localhost:8099/api/convertII/55’. This request has been blocked; the content must be served over HTTPS.

Regards

I’m on the verge of collapsing with this issue

making the indicated modification

[ApiMethod(HttpApiPath = “verpersona/{value}{Item}”, HttpApiMethod = ApiRequestMethod.Post)]
public Persona verpersona(int value, Persona Item)
{
return Item;
}

and from “editor.swagger” generate the client a couple of times correctly

then do something wrong … I do not know what
and it does not let me generate the client.

Errors

Semantic error at paths./verpersona/{value}{Item}
Declared path parameter “Item” needs to be defined as a path parameter at either the path or operation level
Jump to line 25
Semantic error at paths./verpersona/{value}{Item}.post.parameters[1]
Operation parameters must have unique ‘name’ + ‘in’ properties
Jump to line 33
Schema error at paths[’/verpersona/{value}{Item}’].post.parameters[1]
should NOT have additional properties
additionalProperty: $ref, name, in, required
Jump to line 33
Schema error at paths[’/verpersona/{value}{Item}’].post.parameters[1].in
should be equal to one of the allowed values
allowedValues: body, header, formData, query
Jump to line 34
Semantic error at paths./verpersona/{value}{Item}.post.parameters.1.$ref
1 $refs cannot match any of the following: “#/definitions”, “#/responses
Jump to line 36
server.txt (1.7 KB)

You try to define something rally odd and non-working here.

This path definition wouldn’t work: verpersona/{value}{Item}

There is

  1. No separator between {value} and {Item}. In other words there is no way to understand where one value ends and other starts.
  2. Complex type CANNOT be passed as a part of Uri. Only pimitive types like string, number etc are suported as a part of Uri.

You need to define your method as

[ApiMethod(HttpApiPath = “verpersona/{value}”, HttpApiMethod = ApiRequestMethod.Post)]
public Persona verpersona(int value, Persona Item)
{
  return Item;
}

and to pass the Persona instance via request body.

See my Postman screenshot - it clearly shows how reuest and response will look like in this case.