API Explorer (/ui) doesn't serialize JSON correctly

I think the image explains it all:

I’m trying to send this JSON to my API, something that works with Postman, preferably in the body and not the query string, but it serializes as “object”.

This limits the usefulness of the API Explorer.

Presumably SearchGroups is a GET API? which needs to be sent in the queryString, how does Postman know how to send an object in the queryString?

With Postman I can just put something in the body, it doesn’t know.

Even w. query-string, the JSON should be serialized correctly, right?

JSON doesn’t go on the queryString, but the free-text JSON textarea syncs with the form UI inputs which are all non-complex values.

Is this a GET or POST API?

It’s a GET API because it’s search.

I’d like to be able to send data to my API for fields that doesn’t appear in the form (the form inputs only works for non-complex values, so for objects I just pass the JSON I know will deserialize into the correct object)

Right Search should be a GET API, so how does it work in Postman?

What request are you sending it?

You’re making it sound like it’s a normal supported functionality, but GET APIs typically never have any complex objects since there’s no standard way to send them and it makes it less accessible since there’s no standard way for HTTP Clients to send them on the queryString.

I did not get it to work with URL params though.

What does the queryString for this request look like?

There are no parameters other than the body.

It’s just that there’s no way for me to express the boolean expressions that I can with JSON using only query parameters.

My API understands the following, and builds smart SQL to query it:

    "conditions": {
        "and":[
            {"requireKeyword":"managers"},
            {"requireKeyword":"reports"},
            "or":[
                {"requireKeyword":"a"},
                {"requireKeyword":"b"}
             ]
        ],
    }

APIs with complex object graphs should really be a POST.

ServiceStack GET APIs only supports sending complex objects using JSV via the queryString.

So you can try sending the request with JSV Format, e.g:

{
     "conditions": "{requireKeyword:71500}"
}
1 Like

Yeah, that works. Took a few seconds to understand whitespace not allowed, but here’s the result:

Even says here:

JSV can be used to send complex types in a GET request,

Yeah like it says in the docs, though AFAIK ServiceStack is the only fx that supports sending complex types in queryStrings since there’s no standard for it so you should be aware adding complex objects to GET Requests makes APIs less interoperable and accessible. It’s ok if it’s only going to be accessed internally since you can control all clients that can call it, but normally GET requests should only have simple key=value pairs so they’re accessible from all HTTP Clients.

1 Like

Just $0.02 more unsolicited feedback, if this API is to ever be consumed by another person, requiring data in the body of a get, while technically possible, will be extremely confusing to the next person. It just isn’t done.

Yeah, I realize that. Perhaps I’ll switch to POST, it’s kind of a corner case, since it’s search, so I’m just getting something, with no side-effects, but I need a body to express a bit more comples data than what a query string offers. I’m the only consumer anyway, but I do see the point. I’ll checkout what GraphQL uses, that’s kind of the same I guess (a serach w. complex query). Thanks for chipping in.