Forum Discussion
problems with POST call on REST API
- 4 years ago
Hi Anonymous
Try explicitly using HTTPS, your query currently is not.
https://localhost:5000/v1/api/iserver/secdef/searchRegards
Phil
Apart from the the missing accept header it looks benign. Care to try adding that?
Hi and thanks.
Can you point me to a resource which may explain that to me, or suggest how the syntax looks ?
there's nothing to drill down into at MS in this link: https://docs.microsoft.com/en-us/powerquery-m/web-contents.
In the other examples I got working, there wasn't anything that resembled an inbound header (or the like).
Cheers
Rohan
- lbendlin4 years ago
Super User
headers = [#"Content-Type" = "application/json", Accept = "application/json"]
- Anonymous4 years agoNot applicable
Hi
Thanks for the efforts to help find a solution. I made many minor changes to the code in the path to find a solution, and it seems the solution was to amend "http://" to "https://". I commend the code below as the "solution" (which includes a few comments which are redundant trials, as well as some shaping to visually show me some results), and I thank all who helped.
let
url = "https://localhost:5000/v1/api/iserver/secdef/search",
//cookiestr = "get the value of bm_sv cookie from browser",
headers = [#"Content-Type" = "application/json; charset=uts-8"], //, accept = "application/json"], //, Cookie = cookiestr],
query= Json.FromValue(
[
symbol = "BHP",
name = true,
secType = "STK"
]),
body = Json.FromValue(
//body = Text.ToBinary(
[
symbol = "BHP",
name = true,
secType = "STK"
//exchange = "ASX"
]
),
//Content = Text.ToBinary(body),
//add error capture "try"
//handle it down the track
response = try Web.Contents(
url,
[
//RelativePath = "iserver/secdef/search",
Headers = headers,
Content = body
//Query = query
]
),
// Content = Text.ToBinary(body),
// add error capture "try"
// handle it down the track
Value = response[Value],
#"Imported JSON" = Json.Document(Value,65001),
#"Converted to Table" = Table.FromList(#"Imported JSON", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"conid", "companyHeader", "companyName", "symbol", "description", "restricted", "fop", "opt", "war", "sections"}, {"Column1.conid", "Column1.companyHeader", "Column1.companyName", "Column1.symbol", "Column1.description", "Column1.restricted", "Column1.fop", "Column1.opt", "Column1.war", "Column1.sections"})
in
#"Expanded Column1"thanks again.
RT