Parse HTML in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 02:43 AM
I have a HTML string as a response of a REST call-
"Response JIRA Create: <HTML><HEAD><TITLE></TITLE></HEAD><BODY onLoad="document.AUTOSUBMIT.submit();">This page is used to hold your data while you are being authorized for your request.<BR><BR>You will be forwarded to continue the authorization process. If this does not happen automatically, please click the Continue button below.<FORM NAME="AUTOSUBMIT" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="https://sso.xxxx.com/weblogin/public/login.jsp?TYPE=33554433&REALMOID=06-000e765c-3f3d-176d-a2c9-0f1..."><INPUT TYPE="HIDDEN" NAME="SMPostPreserve" VALUE="L65H0DURlQaDk6YiOIcE2iY0JqP/1G1PkJ9mkqBrl3EcuXJrA97aX5R37gJVxfKabNZtbSDVcO4vfD77n7mrWIsJC33/lNUFjKd5OspGOFNp3d0zhsMVF3NqWxjRumh8dRMBTSAFka1Qdati1n3WgU6sRoFyIdSkNNe4jBtslaIBHcV5LdHJcwbhgTixVcB48Wq+DKKTTkTswYe6HPA4PKVQSn4EB+PF33LouwzSTgPNVeJeyFMljy9XPeqwz8xp4GBI2pG2VkA/qFtoTbSQbO3bDUihzTq9nY2uYMF0Jmovl7XGA3pkatov/k226FFPnOrFtnpMtamVoa2Wjxxpxdlkj+oLGXFY9qFd6XzTg6S3GRehPmwYTS/y0yCDWn1IM+0l7jToL/i3pOYERCEgT/A/8Q5GXr3MqoFfpHeQA0RJAFhP3s22ASmo96123nyxuPh2oLhv88jdu3W4Cbmc3JCGH4gUbMbTWDP/SemiuswKMZZOOkqsS/RKuzOhl/0wYa7flgyCW2cjP8IPCpQhAUoJg6q9AXIJPCyrHa8Bzlra2qZA+Dmh3MlDFa5TwWLydiaMRoEOLvrgDWd9dktpgaAPcfXQrtjS2L87J/BBAsMkZeESUzbi9QapKlGxfk3puR1U0uqaY5MGRQZ/n6bY66ZGHyNwOGJk613/cyGcBEndF4ouIsAzUVSjXqsS1Hb7qNEEO4U6RbOKuzV8U0UaytFKQaCPKGkxeuVyVUQq4qAqEfCYqXvdfVVgNkPpV9rVtB9UybXbekJSVe2QaRecM3KnvIpqy6rgwKGWBE4F96jEsdYfQGo1O3xYaKqouTd6SmmuAbi6b43Z3o/UffGIpnQAn0pr5lA2eUciY2+lXRUHTC1ewgyhIaTQ0KmgkAEro+YwutSCUmRvC+hYLdg0I/LNKorTCS4SJCpc7Q85XsL6+EPQb0qOQILFh2MbAz1G"><INPUT TYPE="SUBMIT" VALUE="Continue"></FORM></BODY></HTML>"
I need to get the highlighted value. Can anyone please help me hot to decode this HTML string and get the VALUE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 03:07 AM
Hi Rituparna,
Is this a response from some API either SOAP based or REST based?
If yes then this is not a valid response because if the API is SOAP based then you should get valid XML i.e. well formed xml response
If it is REST based it should be well formed XML or JSON object
First check on that piece.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 03:27 AM
Hi Ankur,
This is a response of REST API. I know that for REST call I should have JSON response and for SOAP i should get XML. But this response is landing me to a html page. I need to get the highlighted value and add to another call. This is why I need to decode this HTML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 03:42 AM
Hi Rituparna,
It is not always that REST API would return JSON object. REST supports xml, json etc as response format as well.
I think while consuming the endpoint you are not setting this parameter which says browser/system which is consuming this endpoint expects a xml response
application/xml or application/json.
You can still achieve of fetching the value using some xml parsing and string manipulation which is not recommended method.
if you get valid xml response or valid json data it would be easier to parse that rather than doing string manipulation on the invalid xml response received.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2017 02:28 AM
Hi Rituparna,
Any update on this?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader