ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to Parse JSON Response from HTTPRequest Node

Post new topic  Reply to topic
 How to Parse JSON Response from HTTPRequest Node « View previous topic :: View next topic » 
Author Message
MrLight
PostPosted: Fri Sep 16, 2022 4:54 am    Post subject: How to Parse JSON Response from HTTPRequest Node Reply with quote

Novice

Joined: 04 Aug 2022
Posts: 14

Hello team ,

I have a use case for calling a webservice Rest API using IIB through HttpRequest Node.

I am able to create a flow with
HttpInput Node --> Compute Node --> HTTPRequestNode--> Compute Node --> HttpReply Node ,


I am sending input data using HTTP Rest client (Postman) , and when I was in debug mode or in the trace log file , that data is sent to service URL that specified in the HTTPRequest node , then routed to error terminal and i see Unknown parser followed by BLOB data

The following is an example of the generated exception:


Code:
Message is:
( ['WSRoot' : 0x1ba360cd6e0]
  (0x01000000:Name):Properties         = ( ['WSPROPERTYPARSER' : 0x1ba341017c0]
    (0x03000000:NameValue):MessageSet             = '' (CHARACTER)
    (0x03000000:NameValue):MessageType            = '' (CHARACTER)
    (0x03000000:NameValue):MessageFormat          = '' (CHARACTER)
    (0x03000000:NameValue):Encoding               = 546 (INTEGER)
    (0x03000000:NameValue):CodedCharSetId         = 1208 (INTEGER)
    (0x03000000:NameValue):Transactional          = FALSE (BOOLEAN)
    (0x03000000:NameValue):Persistence            = FALSE (BOOLEAN)
    (0x03000000:NameValue):CreationTime           = GMTTIMESTAMP '2022-09-16 12:42:36.770' (GMTTIMESTAMP)
    (0x03000000:NameValue):ExpirationTime         = -1 (INTEGER)
    (0x03000000:NameValue):Priority               = 0 (INTEGER)
    (0x03000000:NameValue):ReplyIdentifier        = X'000000000000000000000000000000000000000000000000' (BLOB)
    (0x03000000:NameValue):ReplyProtocol          = 'SOAP-HTTP' (CHARACTER)
    (0x03000000:NameValue):Topic                  = NULL
    (0x03000000:NameValue):ContentType            = 'application/json' (CHARACTER)
    (0x03000000:NameValue):IdentitySourceType     = '' (CHARACTER)
    (0x03000000:NameValue):IdentitySourceToken    = '' (CHARACTER)
    (0x03000000:NameValue):IdentitySourcePassword = '' (CHARACTER)
    (0x03000000:NameValue):IdentitySourceIssuedBy = '' (CHARACTER)
    (0x03000000:NameValue):IdentityMappedType     = '' (CHARACTER)
    (0x03000000:NameValue):IdentityMappedToken    = '' (CHARACTER)
    (0x03000000:NameValue):IdentityMappedPassword = '' (CHARACTER)
    (0x03000000:NameValue):IdentityMappedIssuedBy = '' (CHARACTER)
  )
  (0x01000000:Name):HTTPResponseHeader = ( ['WSRSPHDR' : 0x1ba360cda10]
    (0x03000000:NameValue):X-Original-HTTP-Status-Line = 'HTTP/1.1 400 Bad Request' (CHARACTER)
    (0x03000000:NameValue):X-Original-HTTP-Status-Code = 400 (INTEGER)
    (0x03000000:NameValue):Date                        = 'Fri, 16 Sep 2022 12:42:38 GMT' (CHARACTER)
    (0x03000000:NameValue):Content-Type                = 'application/json' (CHARACTER)
    (0x03000000:NameValue):Transfer-Encoding           = 'chunked' (CHARACTER)
    (0x03000000:NameValue):Server                      = 'Jetty(9.4.34.v20201102)' (CHARACTER)
  )
  (0x01000000:Name):BLOB               = ( ['none' : 0x1ba3611b2a0]
    (0x03000000:NameValue):UnknownParserName = '' (CHARACTER)
    (0x03000000:NameValue):BLOB              = X'7b226572726f72436f6465223a22353030222c226572726f724d657373616765223a2247656e6572616c204572726f72227d' (BLOB)
  )
)


what you recommend of how to overcome this problem and how can i parse the response the will be received from the HTTPRequets node ?
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Sep 16, 2022 12:03 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1638

So that error message is:
Code:
{"errorCode":"500","errorMessage":"General Error"}


So if the server always sends back a JSON reply, you could use a compute node and the JSON parser to parse it,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
MrLight
PostPosted: Sat Sep 17, 2022 8:54 am    Post subject: Reply with quote

Novice

Joined: 04 Aug 2022
Posts: 14

mgk wrote:
So that error message is:
Code:
{"errorCode":"500","errorMessage":"General Error"}


So if the server always sends back a JSON reply, you could use a compute node and the JSON parser to parse it,


yes dear , i realize what you said and i already do this by a json parser but sometimes the response is returned with status code 400 so it received through the error terminal by the default parser BLOB as above that i shared what i need here is how to parse the BLOB response to a JSON and print it out on the client
Back to top
View user's profile Send private message
MrLight
PostPosted: Sat Sep 17, 2022 10:07 am    Post subject: Reply with quote

Novice

Joined: 04 Aug 2022
Posts: 14

MrLight wrote:
mgk wrote:
So that error message is:
Code:
{"errorCode":"500","errorMessage":"General Error"}


So if the server always sends back a JSON reply, you could use a compute node and the JSON parser to parse it,


yes dear , i realize what you said and i already do this by a json parser but sometimes the response is returned with status code 400 so it received through the error terminal by the default parser BLOB as above that i shared what i need here is how to parse the BLOB response to a JSON and print it out on the client


Solved for me by trying with the different solutions as the following that cast the BLOB data response the retrieved from the error terminal of HTTPRequest node to JSON by ESQL through a compute node :

SET OutputRoot = InputRoot;
DELETE LASTCHILD OF OutputRoot;
CREATE LASTCHILD OF OutputRoot DOMAIN ('JSON') PARSE (InputRoot.BLOB.BLOB);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to Parse JSON Response from HTTPRequest Node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.