Not able to read HTML response in Apigee

Hi,

Struggling to get hold of a response in Apigee in case of pure HTML structure. 

I have a HTML response like

<html><head><title>yo man</title><head><body>something goes in here</body></html>.

 

I have tried various mechanisms like Extract Variable Policy from Response,  Assign Variable Policy Copy from Response, Javascript use of various flow variables but none of those options are working.

 

Is there anybody could please suggest to catch a pure HTML response in Apigee?  

 

Tagging for your help please dchiesa1 @apigee @Former Community Member @Former Community Member 

1 7 443
7 REPLIES 7

It's not really clear from your question what you're trying to achieve. The target response will be in the response.content variable.

 

Are you trying to parse the HTML?

Please check the Content-Type header. XML payloads are extracted only when the Content-Type header of the message is text/xmlapplication/xml, or application/*+xml.

Refer: https://docs.apigee.com/api-platform/reference/policies/extract-variables-policy#xmlpayloadelement

Sorry for the late response. I have had no notification.

The HTML response is from WAF (which I can't change) in case of any special characters in the request. So when a response is returned from WAF - the response.content is empty. So I can't parse HTML response to pick some important info from the response and convert it into JSON.

 

content-type is plain text HTML and not XML.

Apigee is not a good tool for parsing HTML responses. What are you really trying to do?

Hi, @mmtechsoft 

From your question I can understand that your given web service returns responses also in the HTML format. You may want to have responses in the JSON or XML to use all the capabilities of the policies & Debug of the Apigee.

thanks, regards, Yermek

Sorry for the late response. I have had no notification.

The HTML response is from WAF (which I can't change) in case of any special characters in the request. So when a response is return from WAF - the response.content is empty. So I can't parse HTML response to pick some important info from the response and convert it into JSON.

I'm not sure what the question is then.  I thought the original question was "how can I parse HTML?" 

But now you are telling me that "response.content is empty".  Which means there is no HTML to parse.

Can you review, what exactly is the question? and also, stepping back, what are we solving for here? Can you describe more broadly why there is HTML involved at all?  

Just to restate: Apigee is an API Proxy.  It's not intended to handle HTML, parse HTML, or manipulate HTML.  If you are interested in a system that handles, inspects, parses, or manipulates HTML, Apigee is not that system. If your question is "help me configure Apigee to inspect, parse, or manipulate HTML", then I cannot help you.