Http request: Unable to read JSON request payload - power-automate

I have a flow triggered by Microsoft form. The only part the HTTP request (creates a draft in outlook) keeps giving error.
Form -> Excel -> Http request
The raw input is good, everything comes into this correct. But the output keeps giving error Bad request
Unable to read JSON request payload. Please ensure Content-Type header
is set and payload is of valid JSON format
Can you guys run over the code if i missed something?
{
"subject":"CAT Recruiter Candidate Call Audit Results: #{outputs('Add_a_row_into_a_table')?['body/Recruiter Name_x003a_']} via #{outputs('Add_a_row_into_a_table')?['body/Consultant Candidate Name_x003a_']} (#{outputs('Add_a_row_into_a_table')?['body/Consultant Candidate Technology_x003a_']}) - #{outputs('Add_a_row_into_a_table')?['body/Average Score']} of 5 | #{outputs('Add_a_row_into_a_table')?['body/Overall Average Rank']}",
"importance":"normal",
"body":{
"contentType":"HTML",
"content":"Hello #{outputs('Add_a_row_into_a_table')?['body/Recruiter Name_x003a_']},
<br />
<style>
Table {
font-family: Arial, Helvetica, sans-serif;
background-color: #d4d4d4;
border-collapse: collapse;
width: 70%;
}
Table td, Table th {
border: 1px solid #ddd;
padding: 3px 3px;
}
Table th {
font-size: 14px;
font-weight: bold;
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #025db0;
color: white;
}
</style>
Please find the results of a recent CAT Recruiter candidate call audit for your #{outputs('Add_a_row_into_a_table')?['body/Consultant Candidate Technology_x003a_']} candidate #{outputs('Add_a_row_into_a_table')?['body/Consultant Candidate Name_x003a_']},
<br />
<br />
<u><h2><center>Preliminary Data</center></u></h2>
<br/>
<Table>
<th><u>Concept</u></th>
<th><u>Comment (Auditor Input)</u></th>
</TR>
<tr>
<TD>Link to the Recruiter Script Call:</td>
<TD><a href=' #{outputs('Update_a_row_2')?['body/Link to the Recruiter Script Call_x003a_']}'> Click here! </a></td>
</tr>
<tr>
<TD>Duration of Recruiter Script Call:</td>
<TD>#{outputs('Update_a_row_2')?['body/Duration of Recruiter Script Call_x003a_']}</td>
</tr>
<tr>
<TD>Recruiter Name:</td>
<TD>#{outputs('Add_a_row_into_a_table')?['body/Recruiter Name_x003a_']}</td>
</tr>
<tr>
<TD>Consultant Candidate Name:</td>
<TD> #{outputs('Add_a_row_into_a_table')?['body/Consultant Candidate Name_x003a_']}</td>
</tr>
<tr>
<TD>Date Call Occurred:</td>
<TD> #{formatDateTime(outputs('Get_response_details')?['body/rf2996f66aca742cbb5f343554dfca267'],'M/dd/yyyy')}</td>
</tr>
<tr>
<TD>Date Call uploaded:</td>
<TD>#{formatDateTime(outputs('Get_response_details')?['body/rde92ba696f4144cf957fac2f0ec53674'],'M/dd/yyyy')} </td>
</tr>
<tr>
<TD>Days between call and upload: </td>
<TD>#{outputs('Update_a_row_2')?['body/Count of Days Between Call Occurred vs_x002e_ Uploaded_x003a_']}</td>
</tr>
<tr>
<TD>Date Assessment Completed:</td>
<TD>#{formatDateTime(outputs('Get_response_details')?['body/ra129276496b2431b96a485ae105e75bf'],'M/dd/yyyy')} </td>
</tr>
<tr>
<TD>Consultant Candidate Technology:</td>
<TD> #{outputs('Update_a_row_2')?['body/Consultant Candidate Technology_x003a_']}</TD>
</tr>
<tr>
<TD>Candidate Stage At Time of Audit:</td>
<TD> #{outputs('Update_a_row_2')?['body/Candidate Stage At Time of Audit']}</td>
</tr>
<tr>
<TD>Average Score</td>
<TD>#{outputs('Update_a_row_2')?['body/Average Score']}</td>
</tr>
<tr>
<TD>Overall Rank</td>
<TD>#{outputs('Update_a_row_2')?['body/Overall Average Rank']}</td>
</tr>
</table>
<h2><u><center>Assessment</center></u></h2>
<br/>
<Table>
<Th><u>Concept/Competency</u></TH>
<Th><u>Rank (Below - Exceed or N/A)</u></TH>
<th><u>Comment (Auditor Input)</u></th>
</TR>
<tr>
<td>Recruiter Tonality: </td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter Tonality_x003a_']} </td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter Tonality_x003a_ (Auditor Input)']}</td>
</tr>
<tr>
<td>Candidate Tonality: </td>
<td>#{outputs('Update_a_row_2')?['body/Candidate Tonality_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Candidate Tonality_x003a_ (Auditor Input)']}</td>
</tr>
<tr>
<td>Recruiter's Ability to Not Sound Like a Script: </td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter''s Ability to Not Sound Like a Script_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter''s Ability to Not Sound Like a Script_x003a_']}</td>
</tr>
<tr>
<td>Recruiter's Ability to Sell the Role: </td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter''s Ability to Sell the Role_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter''s Ability to Sell the Role_x003a_']}</td>
</tr>
<tr>
<td>Recruiter's Ability to Answer Ad Hoc Questions: </td>
<td>#{outputs('Add_a_row_into_a_table')?['body/Recruiter''s Ability to Answer Ad Hoc Questions_x003a_']}</td>
<td>#{outputs('Update_a_row_2')?['body/Comment Recruiter''s Ability to Answer Ad Hoc Questions_x003a_']}</td>
</tr>
<tr>
<td>Recruiter's Understanding of Our Business Model:</td>
<td> #{outputs('Update_a_row_2')?['body/Recruiter''s Understanding of Our Business Model_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter''s Understanding of Our Business Model_x003a_']}</td>
</tr>
<tr>
<td>Candidate's Fit for Role Based on Script Conversation: </td>
<td>#{outputs('Update_a_row_2')?['body/Candidate''s Fit for Role Based on Script Conversation_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Candidate''s Fit for Role Based on Script Conversation_x003a_']}</td>
</tr>
<tr>
<td>Recruiter Communicating Nationwide/EU Travel Effectively: </td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter Communicating Nationwide~1EU Travel Effectively_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter Communicating Nationwide~1EU Travel Effectively_x003a_']}</td>
</tr>
<tr>
<td>Recruiter Communicating Financial Commitment Effectively:</td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter Communucating Financial Commitment Effectively']}</td>
<td>#{outputs('Update_a_row_2')?['body/Comment Recruiter Communucating Financial Commitment Effectively']}</td>
</tr>
<tr>
<td>Recruiter Communicating Marketing Requirements Effectively:</td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter Communucating Marketing Requirements Effectively_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter Communucating Marketing Requirements Effectively_x003a_']}</td>
</tr>
<tr>
<td>Recruiter Communicating Compensation Effectively</br>
(Project Rate, Bench Rate, Performance Reviews): </td>
<td>#{outputs('Update_a_row_2')?['body/Recruiter Communucating Compensation Effectively (Project Rate, Bench Rate, Performance Reviews)_x003a_']}</td>
<td> #{outputs('Update_a_row_2')?['body/Comment Recruiter Communucating Compensation Effectively (Project Rate, Bench Rate, Performance Reviews)_x003a_']}</td>
</tr>
<tr>
<td>Overall Rank:</td>
<td><b> #{outputs('Update_a_row_2')?['body/Overall Average Rank']}</b></td>
</tr>
</table>
<br/>
<table>
<TH>Overarching Themes Needing Improvement (Auditor Input)</TH>
</table>
<table>
<TD>#{outputs('Update_a_row_2')?['body/Overarching Themes Needing Improvement (Auditor Input)']}</TD>
</table>
</u>
<br/>
<br/>
Here you can find the definitions for CAT Scoring & Terminology:<a href='#{outputs('Create_share_link')?['body/WebUrl']}'> Click here! </a>
<br/>
<br/>
<br/>
<b>Thanks! </b>
<br/>
</br>
</br>
"
},
"toRecipients":[
{
"emailAddress":{
"address":
}
}
]
}

Related

Why Xpath 3.0 works, but Xquery 3.0 doesn't work with the same expression

I launched Xpath in Oxygen. In Xpath 3.0 found what i need but in Xquery 3.0 doesn't find.
This is my Xpath expression
//table[tbody/tr/th/p[contains(text(), 'All Water System Contacts')]]/tbody/tr[3]/td[1]
This is my xml code
I put part code.
<table border="1" cellpadding="1" cellspacing="1" summary="." width="640">
<tbody>
<tr>
<th colspan="3">
<p>All Water System Contacts </p></th>
</tr>
<tr>
<th>Type</th>
<th>Contact</th>
<th>Communication</th>
</tr>
<tr>
<td align="center">AC - Administrative Contact - GENERAL MANAGER </td>
<td align="center">GRANT, JOHN, W <br/> PO BOX 869<br/> BIG SPRING, TX 79721-0869 </td>
<td align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
width="100%">
<tbody>
<tr>
<th><b>Electronic Type</b></th>
<th><b>Value</b></th>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
width="100%">
<tbody>
<tr>
<th><b>Phone Type</b></th>
<th><b>Value</b></th>
</tr>
<tr>
<td align="center">BUS - Business</td>
<td align="center">432-267-6341 </td>
</tr>
<tr>
<td align="center">FAX - Facsimile</td>
<td align="center">432-267-3121 </td>
</tr>
<tr>
<td align="center">BUS - Business</td>
<td align="center">432-267-6070 </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center">OW - Owner </td>
<td align="center">COLORADO RIVER MUNICIPAL WATER DISTRICT <br/> PO BOX 869<br/> BIG
SPRING, TX 79721-0869 </td>
<td align="center"> </td>
</tr>
</tbody>
</table>
I tried different functions.
I don't know why it doesn't work and what difference
Please help me.
I suspect your real, complete input has an XHTML default namespace declaration xmlns="http://www.w3.org/1999/xhtml" and in oXygen for XPath you have the setting enabled to "use the default namespace of the root element" so your path works with XPath out of the box while for XQuery you need to make sure you explicitly set
declare default element namespace 'http://www.w3.org/1999/xhtml';
in the prolog of your XQuery file or code sample.

Optimal XPath Query for processing the sample HTML fragment

I have a feed that outputs HTML. The following segment is part of the output
<div class="leftnav">
<table border="0" cols="2">
<tr>
<td colspan="2" class="topline"><span style="font-size: 1px"> </span></td>
</tr>
<tr>
<td colspan="2"><span class="bold">Article Cat1 </span></td>
</tr>
<tr>
<td class="date" colspan="2">
ArticleTitle1</td>
</tr>
<tr>
<td width="20"></td>
<td class="date">
ArticleLink1
</td>
</tr>
<tr>
<td colspan="2" class="topline"><span style="font-size: 1px"> </span></td>
</tr>
<tr>
<td colspan="2"><span class="bold">Article Cat2 </span></td>
</tr>
<tr>
<td class="date" colspan="2">
ArticleTitle2</td>
</tr>
<tr>
<td width="20"></td>
<td class="date">
ArticleLink2
</td>
</tr>
</table>
</div>
I want to process above segment using XPATH so that output looks like this
Article Cat1
ArticleTitle1
ArticleLink1 Article Cat2
ArticleTitle2
ArticleLink2
What is the optimal XPATH that will produce the desired output? I tried //div[#class="leftnav"]/table/tr but this gives all the TR elements. I want to skip the first TR element so that I can get the output in the format I described above.
//div[#class="leftnav"]/table/tr[position() > 1]
Try the above
Stupid simple way:
substring-after(normalize-space(string(//*:div)), normalize-space(string(//*:div/*:table/*[1])))
Result: "Article Cat1 ArticleTitle1 ArticleLink1 nbsp Article Cat2 ArticleTitle2 ArticleLink2"
I don't know why, but (position() > 1) doesn't work in my environment, so I've used strings instead.

Need help to locate the text of element with class?

I have a file that I have got using the command page.css("table.vc_result span a"), I am not able to get the second and third Span element of the file:
File
<table border="0" bgcolor="#FFFFFF" onmouseout="resDef(this)" onmouseover="resEmp(this)" class="vc_result">
<tbody>
<tr>
<td width="260" valign="top">
<table>
<tbody>
<tr>
<td width="40%" valign="top"><span><a class="cAddName" href="/USA/Illinois/Chicago/Yellow+Page+Advertising+And+Telephone+Directory+Publica/gateway-megatech_13478733">
Gateway Megatech</a></span><br>
<span class="cAddText">P.O. BOX 99682, Chicago IL 60696</span></td>
</tr>
<tr>
<td><span class="cAddText">Cook County Illinois</span></td>
</tr>
<tr>
<td><span class="cAddCategory">Yellow Page Advertising And Telephone
Directory Publica Chicago</span></td>
</tr>
</tbody>
</table>
</td>
<td width="260">
<table align="center">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>
<div style=
"background: url('images/listings.png');background-position: -0px -0px; width: 16px; height: 16px">
</div>
</td>
<td><font style="font-weight:bold">847-506-7800</font></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tbody>
<tr>
<td>
<div style=
"background: url('images/listings.png');background-position: -0px -78px; width: 16px; height: 16px">
</div>
</td>
<td><a href=
"/USA/Illinois/Chicago/Yellow+Page+Advertising+And+Telephone+Directory+Publica/gateway-megatech_13478733"
class="cAddNearby">Businesses near 60696</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
...This is not the complete file there are plenty more span entries in that file.
The code that I am using is able to locate the exact text but not able to associate it with the text of the nested element Span A.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
name="yellow"
city="Chicago"
state="IL"
burl="http://www.sitename.com/"
url="#{burl}Business_Listings.php?name=#{name}&city=#{city}&state=#{state}&current=1&Submit=Search"
page = Nokogiri::HTML(open(url))
rows = page.css("table.vc_result span a")
rows.each do |arow|
if arow.text == "Gateway Megatech"
puts(arow.next_element.text)
puts("Capturing the next span text")
found="Got it"
break
else
puts("Found nothing")
found="None"
end
end
Assuming that each business is a new <tr> inside the top table you have supplied, the following code gives you an array of Hashes with the values:
require 'nokogiri'
doc = Nokogiri.HTML(html)
business_rows = doc.css('table.vc_result > tbody > tr')
details = business_rows.map do |tr|
# Inside the first <td> of the row, find a <td> with a.cAddName in it
business = tr.at_xpath('td[1]//td[//a[#class="cAddName"]]')
name = business.at_css('a.cAddName').text.strip
address = business.at_css('.cAddText').text.strip
# Inside the second <td> of the row, find the first <font> tag
phone = tr.at_xpath('td[2]//font').text.strip
# Return a hash of values for this row, using the capitalization requested
{ Name:name, Address:address, Phone:phone }
end
p details
#=> [
#=> {
#=> :Name=>"Gateway Megatech",
#=> :Address=>"P.O. BOX 99682, Chicago IL 60696",
#=> :Phone=>"847-506-7800"
#=> }
#=> ]
This is pretty fragile, but works for what you've given, and there do not seem to be very many semantic items to hang onto in this insane, horrorific abuse of HTML.
Parsing HTML with regular expressions is a bad idea, because HTML is not a regular language. Ideally, you want to parse the DOM / XML to a tree structure.
http://nokogiri.org/ is pretty popular.

Parse table in HTML Agility Pack for WP7

I have following HTML:
<table cellspacing="8" cellpadding="6" border="1" style="color: Black; background-color: LightGoldenrodYellow;
width: 60%;" id="GridView2" rules="all">
<tbody>
<tr style="color: White; background-color: #CF4B0A; font-weight: bold;">
<th align="center" scope="col">
Booked At
</th>
<th align="center" scope="col">
Booked On
</th>
<th align="center" scope="col">
Delivered At
</th>
<th align="center" scope="col">
Delivered On
</th>
<th scope="col">
Details
</th>
</tr>
<tr align="left" style="color: #333333; background-color: #FFFBA1; font-family: Arial;
font-size: Small;">
<td align="center">
Not Available
</td>
<td align="center">
Not Available
</td>
<td align="center">
DATA
</td>
<td align="center">
12/01/2012
</td>
<td>
<a href="javascript:__doPostBack('GridView2$ctl02$LinkButton1','')" id="GridView2_ctl02_LinkButton1">
Details</a>
</td>
</tr>
</tbody>
</table>
I would like to parse the above table using HTML Agility pack. I'm using the HAP solution for WP7, downloaded from Codeplex.
Any quick help will be appreciated.
To parse the HTML, use HAP's HtmlDocument.LoadHtml() function and pass it the actual string. That will give you a DOM with all the HTML objects in it.

Finding table values in watij using xpath

I am using watij to automate my UI testing. I have many tables in a webpage. I need to find a table which has a width 95%. It contains many rows. I have to find each row with different text say "running first UI test on local" as below adn need to get the td value "Complete". I am not ble to get the value but I get the watij address. Let me know how I can find this.
<table width=95%>
<tr>
<th align="left">
<span id="lblHeaderComponent" style="font-size:10pt;font-weight:bold;">Component</span>
</th>
<th align="left">
<span id="lblHeaderServer" style="font-size:10pt;font-weight:bold;">Server</span>
</th>
<th align="left">
<span id="lblHeaderStatus" style="font-size:10pt;font-weight:bold;">
</span>
</th>
</tr>
<tr>
<td align="left"
nowrap="nowrap" style="font-size:12px;">running first UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
<tr>
<td align="left"
style="border-top:1px solid #cfcfcf;border-bottom:1px solid #cfcfcf;"
colspan="3"
style="font-size:12px; color:#ff3300;">
</td>
</tr>
<tr>
<td align="left" nowrap="nowrap" style="font-size:12px;">running second UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
</table>
You can try an xpath visualizer like this one to assist you in getting the right expression. It lets you see the results visually.
Using XPath on HTML assumes the HTML is XHTML - in other words it must be well-formed XML.

Resources