Recent posts:
Tomas has not published any posts yet.
Recent replies:

Please, what is definition of your  stream property and how do you create its data?

If the stream is type of %Library.GlobalCharacterStream or %Library.GlobalBinaryStream, the location of the streams depends if you write data directly to the stream property or if you created the stream first and assign it to stream property:

Class tv.test Extends %Persistent,
{
Property MyStream As %GlobalCharacterStream;
}

USER>s x=##class(tv.test).%New()
 
USER>w x.MyStream.%Location
^tv.testS
USER>w x.MyStream.Write("My Data")
1
USER>w x.%Save()
1
USER>zw x.MyStream.GetStreamId()
$lb($c(0,16,1,11,1)_"^tv.testS"_$c(3,4,4,2,1),"%GlobalCharacterStream"

BUT:

USER>s x=##class(tv.test).%New()
 
USER>s str=##class(%GlobalCharacterStream).%New()
 
USER>w str.%Location
^CacheStream
USER>s x.MyStream=str
 
USER>w x.MyStream.%Location
^CacheStream
USER>w x.MyStream.Write("My Data")
1
USER>w x.%Save()
1
USER>zw x.MyStream.GetStreamId()
$lb($c(0,19,1,14,1)_"^CacheStream"_$c(3,4,2,2,1),"%GlobalCharacterStream")

Therefore if you do not want to change the location of the stream, is better to use CopyFrom method insterad:

USER>s x=##class(tv.test).%New()
 
USER>s str=##class(%GlobalCharacterStream).%New()
 
USER>w str.Write("My Data")
1
USER>w x.MyStream.CopyFrom(str)
1
USER>w x.%Save()
1
USER>zw x.MyStream.GetStreamId()
$lb($c(0,16,1,11,1)_"^tv.testS"_$c(3,4,5,2,1),"%GlobalCharacterStream")

Please, let us know if it corresponds to your findings.

Yone, try to set ContentCharset AFTER setting of  ContentType:

 set httpRequest.ContentType "application/json"
 
set httpRequest.ContentCharset "UTF-8"
 

This is from %Net.HttpRequest class documentation:

property ContentCharset as %String [ Calculated ];

This is the charset to encode the contents with. This is actually specified in the HTTP Content-Type header with something like:

Content-Type: text/html; charset=UTF-8

You must set this property after you set the ContentType or it will overwrite this value.

Will it change anything?

I have tried to test your code and found the Content-Length was set to 0 when ContentCharset was set.

I investigated that it was cased by the code reading the data before Posting to server, therefore the EntityBody stream was at end and calculated size after translation to UTF-8 was zero. 

To fix it you need to rewind the stream before you send it using Post() method:

 set httpRequest.ContentType = "application/json"
 set httpRequest.ContentCharset="utf-8"
...

 Do httpRequest.EntityBody.Write(body.%ToJSON()) while(httpRequest.EntityBody.AtEnd=0){
   set linea = httpRequest.EntityBody.Read()
 }

 Do httpRequest.EntityBody.Rewind() //REWIND the data to start from the beginning after reading !!!
 $$$LOGINFO("linea: "_linea)
 set tSC = httpRequest.Post("https://onesignal.com/api/v1/notifications") set tResponse = httpRequest.HttpResponse

Does it help?

Followers:
Following:
Global Masters badges:
Tomas has no Global Masters badges yet.