HTTP POST Method Syntax

Posted by: anjushaji0007 on 29 August 2024, 3:22 am EST

    • Post Options:
    • Link

    Posted 29 August 2024, 3:22 am EST

    Dear Team,

    Need a demo report for HTTP post request where we can include multiple parameters in the post body while calling an API along with the syntax used in post body method.

    PFB paramater body we need to include in Post body.

    Kindly provide us the syntax.

    body = Text.ToBinary("

    {

    ““ClientCode””: ““35"”,

    ““UserId””: “””“,

    ““TransactionType””: 2,

    ““SearchString””: “””“,

    ““FundRiskRating””: 1,

    ““LastBusinessDate””: ““2021-04-15T09:47:31.294Z””,

    ““FundHouseName””: ““kotak””

    }”),

  • Posted 30 August 2024, 1:29 am EST

    Hi Anju,

    You may specify the body for a POST request in the Post body section of the DataSet designer.

    Please note that ActiveReportsJS uses ‘{’ & ‘}’ to define its custom expressions. When using JSON, one ‘{’ is treated as an escape character in ‘{{’ to treat your JSON as a string instead of an ARJS expression. Hence, you may add the following expression in the Post Body:

    {{
    "ClientCode": "35",
    "UserId": "",
    "TransactionType": 2,
    "SearchString": "",
    "FundRiskRating": 1,
    "LastBusinessDate": "2021-04-15T09:47:31.294Z",
    "FundHouseName": "kotak"
    }
    

    For more details, please refer to the attached documentation links:

    Please run the attached sample using the following steps demonstrating the above:

    1. Run the sample using the following commands:
    npm i
    npm start
    
    1. Open the Developer Console by clicking
      F12
      , and go to the Network tab.
    2. Now preview the report, select the value for the 'fundHouseName_ parameter, and click on Preview.
    3. In the Network tab, you will notice a failed call to ‘Customers’ as the DataSource does not support the specified parameters. However, by clicking on the same, we can verify the values of the passed parameters.
    4. Click on ‘Customers’ and go to the Payload tab; there you’ll find that your selected parameter has been passed into the query as expected!

    We hope this helps!

    Attachment:HTTP_POST_Sample.zip

  • Posted 30 August 2024, 5:43 am EST

    Can you please provide us a demo video for the same.

  • Posted 30 August 2024, 9:25 am EST - Updated 30 August 2024, 9:30 am EST

    Hello Team,

    I tried implementing your “GraphQL Query Arguments” Documentation example but it is not working.

    Please help me with the same.

    While adding Products dataset as mentioned in documentation I am facing the error as “Incorrect query string”.

    Attached below the Screenshot ,Report and Screenshare video.

    Please look into this.

    Incorrect query string.zipPostDemo.zip

  • Posted 2 September 2024, 5:36 am EST

    Hi Anju,

    Thank you for the attachments!

    We could observe the following errors in your attached report, and fixing them resolved the issue at our end:

    1. The error
      '0x0A' is invalid within a JSON string
      indicates that there is an unescaped newline character (0x0A is the ASCII code for a newline) in the query string. JSON strings should not contain raw newlines; they must be properly escaped. You need to ensure that the entire query is a single line without any newline characters. Please refer to the attached query string:

    {{"query":"{{category(id:{@CategoryID}){{products{{productName,unitPrice,unitsInStock}}}"}

    1. We could observe wrong Json Path:. The correct Json Path should be
      $.data.category.products.*
      .

    You may also refer to the attached updated sample. We hope this helps!

    Attachment: PostDemo_Updated.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels