Genexus 16 U10 Java Web -从外部API请求令牌时响应体的截断



我们在通过HTTPClient变量使用Genexus应用程序的外部API时遇到了问题,因为当通过承载方法请求令牌时,API响应的JSON格式的主体到达时被截断,无法解析它以获得接收到的令牌。

示例代码:

&httpclient = new()
&httpclient.Timeout = 30
&httpclient.AddHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8')
&httpclient.AddHeader('Cache-Control','no-cache')
&httpclient.AddHeader('Accept-Encoding','gzip, deflate, br')
&httpclient.AddVariable('client_id','aivoclient_test')
&httpclient.AddVariable('client_secret','bd8ea668-9bbc-2bda-d71e-8299f0cb98df')
&httpclient.AddVariable('grant_type','client_credentials')
&url = 'http://localhost:8085/connect/token'
&httpclient.Execute(HttpMethod.Post, &url)
if not &httpclient.ErrCode.IsEmpty()
&validardatos = 'GENEXUS ERROR'
+ '! errorCode=' + &httpclient.ErrCode.Round(0).ToString().Trim()
+ ', errorDescr=' + &httpclient.ErrDescription
+ ', reasonLine=' + &httpclient.ReasonLine
do 'AddMsg'
do 'Show Messages'
return
endif
&auxResponse = &httpclient.ToString().Trim()
msg('response=' + &auxResponse, nowait)

如果我们尝试从POSTMAN调用API,则Response到达时没有截断,但在我们的GX应用程序中,TOKEN总是截断到达,如图所示。

分析请求,唯一不同的是GX和POSTMAN添加的报头,我们认为一定有问题,但一直无法找到原因。

有没有人知道这个错误可能发生在哪里?

可能http://localhost:8085/connect/token中的变量太小,无法返回所有令牌信息。