Hi Guys,
I'm trying to read a REST API Stream (Json) but something doesn't work.
For example:
i try the same Configuration with Postman and get a json stream, with ca. 2250 KB (Only Body Size)
like this:
IF i use the same Configuration in NAV, and read the Respons, ist look like this.
The Blob Size is exactly the Same (2250 KB).
My Code is this:
Answers
IF GLHttpStatusCode.ToString = GLHttpStatusCode.OK.ToString THEN MESSAGE(myjson)
Also try to store the ResponseStream in Tempblob:
TempBlob.Blob.CREATEINSTREAM(Response);
and then read as following:
myjson := TempBlob.ReadAsText('',TEXTENCODING::UTF8)
the httpstatus is OK, this works
After ".ReadAsText" i Display the message and it Shows nothing
the tempblob Looks like this
Looks like the blob have data, maybe the problem is the READTEXT, try to use READ and WHILE NOT JsonInStream.EOS and see what you got.
Regards.
I Change the Code to
WHILE JsonInStream.READ(NewContent) > 0 DO
FileContent += NewContent;
and get this Content after reading.
maybe the DotNet component is wrong, is it possible that i shoud work with "httpClient" Component?
HttpWebResponse DotNet System.Net.HttpWebResponse.'System, Version=4.0.0.0
HttpStatuscode DotNet System.Net.HttpStatusCode.'System, Version=4.0.0.0
StreamReader DotNet System.IO.StreamReader.'mscorlib, Version=4.0.0.0
JSONresultString DonNet System.String.'mscorlib, Version=4.0.0.0
The value in the dotnet string can be stored in a blob using this:
Please inspect the response headers to see, if you got what you expected. Also, the response might be compressed (and a response header should tell you if this is the case, and also what compression algorithm the server used. If the response is compressed, you should be able to tell the server to not use compression (using a request header), or you may just decompress the response before consuming it.
You could insert a proxy between Nav and the API to inspect the headers in detail and compare with a working scenario.
The Webserver compressed any Response, automaticlly.
The Solution was this Code Line:
HttpWebRequestMgt.SetDecompresionMethod(DecompressionMethod.GZip);