#1002 Writing JSON Payload via nHaystack HTTP API to Endpoint

Phillip K Wed 10 Aug

Hello, following the documentation and the posts within this forum i was able to write a string to an endpoint via the nHaystack HTTP API.

Example: https://serverurl/haystack/pointwrite?id=C.Haystack_Test.TestString&level=16&val=ThisisaStringoraJSONStructure&who=Testuser

When i want to transfer e.g. large JSON structures this stops working when a specific character limit has been reached (2048 characters in the url).

Is it possible to define a JSON as a payload within the http request?

Best regards,

Phillip

Brian Frank Thu 11 Aug

It sounds like you are using a HTTP GET request, when you need to be using a POST request and encoding the request into the body (not the URL). Just note that when using GET you are are using URL query parameters, not JSON. When you actually encode the HTTP JSON payload its going to look more like this:

{
"_kind": "grid",
"meta": {"ver":"3.0"},
"cols": [
{"name":"id"},
{"name":"level"},
{"name":"val"},
{"name":"who"}
],
"rows":[
{"id":{"_kind":"ref", "val":"C.Haystack_Test.TestString", "dis":"C.Haystack_Test.TestString"}, "level":16, "val":"value here", "who":"Testuser"}
]
}

Phillip K Thu 18 Aug

Hi Brian,

thank you for the response. You are absolutely right, i misconfigured the type of request. Changing the GET to a POST and using your scheme as a template now gives me a http error 500 - the payload still seems to be misconfigured somehow. Shouldn't these things be part of the documentation? I think "real-world" examples within the documentation would definitely help to get people started using the http api..

Login or Signup to reply.