Forum Discussion
Bessonnizza
6 years agoHelper II
Json.FromValue
Hello there, I want to write POST request with data for WEB service. I try to use Json.FromValue function to convert to JSON, but it isn't working. JSON data schema: My POST request...
lbendlin
6 years agoSuper User
You want to use Json.Document instead and craft your Json structure manually. Don't think schemas are supported.
data = Json.Document("{Period:{Begin:""begin"",End:""End""},TargetObject:{ObjectId:""ObjectId"",ObjectTypeId:""ObjectTypeId""}}")- Bessonnizza6 years agoHelper II
Does Parameters works in you case? For example
data = Json.Document("{Period:{Begin:"paramBegin",End:"paramEnd"}- lbendlin6 years agoSuper User
Yes, it would work
data = Json.Document("{Period:{Begin:""" & paramBegin & """,End:""" & paramEnd & """},TargetObject:{ObjectId:""" & paramObjectId & """,ObjectTypeId:""" & paramObjectTypeId & """}}")Don't lose any sleep (pun intended) over the double quotes - they are all needed.
- Bessonnizza6 years agoHelper II
try you example and get an error:
Expression.Error: We cannot convert a value of type Record to type Binary.
Details:
Value=[Record]
Type=[Type]let data = Json.Document("{Period:{Begin:""1584428676205"",End:""1584515076205""},TargetObject:{ObjectId:""51005"",ObjectTypeId:""0F1E3A4A-88F5-4166-9BE8-76033DD85D08""}}"), headers = [#"accept"="*/*", #"ScoutAuthorization"=paramAuthorizationId, #"Content-Type"="application/json"], web = Web.Contents("http://url", [ Content = data, Headers = headers, ManualStatusHandling = {404, 400}]), result = Json.Document(web) in result