Authorization and post body syntax API

Posted by: anjushaji0007 on 4 September 2024, 1:38 am EST

  • Posted 4 September 2024, 1:38 am EST - Updated 4 September 2024, 1:43 am EST

    Hello Team,

    We are facing issue in calling Post API .

    Could you please help us with the syntax of below mentioned API details.

    Post Body is used in raw format in postman how can we use the same in active reports.

    let

    url = "

    https://faw24.milessoft.com/V24_Main/ClientPortalv24/24RestAPI/Client/Schemes"

    ,

    headers = [

       #"TPA" = "xyz",
    
       #"TenantId" = "#",
    
       #"Content-Type" = "application/json"
    

    ],

    body = “7joIb/20+DbhFriYaUuuh+2mh590bYwLC7IuVG/tXxTmV1rMaQfz4TcszVfWimzjIN9t9/ipMCFsKR8YK9xxn4jIHVH1qBqJFLbp/OoROtsz4eXzJmH4FBJCm/fccg9vEjpwhrCoH/vJT8oC/VZu7Hlip/7yNOaZNNbNzTm5TKLdE/ZQYIC99bDuPE7d/pPrNFsMY2rPYvYXOhBKjRATI4mvHHE0El6brPcIC/1zb34gPTJVGMH/y0h1nvhCGIPZhZCiS7bhy0XfHA7RJlBSpBPwU01l6hmK1R5lU8nhGBvFJwGezXBq2u5ClHgWYWyz8RCAq5a0QdBJSso7x1Ah/A==”,

    Source = Json.Document(Web.Contents(url, [

       Headers = headers,
    
       Content = Text.ToBinary(body)
    

    ]))

    in

    Source

  • Posted 5 September 2024, 3:00 am EST - Updated 5 September 2024, 3:05 am EST

    Hi Anju,

    Unfortunately, we were not able to test the POST API on your given URL due to a 401-Unauthorized error. However, we tested creating a DataSet in ActiveReportsJS using a POST API on our local data source and it works as expected!

    To do it on your end, you’ll first need to create a DataSource with a URL to “https://faw24.milessoft.com/” Then you’ll need to add a DataSet with Path to “V24_Main/ClientPortalv24/24RestAPI/Client/Schemes”.

    In the Method change HTTP GET to HTTP POST, then in the Post body, you can pass your body.

    In the Headers section, you can add the Header key and its value.

    Please refer to the attached screenshot for reference.

    You can learn more about Data Binding here: Data Binding.

    Regards,

    Anand

    Unauthorized Error:

    DataSet Query

  • Posted 9 September 2024, 12:23 am EST

    Below are actual values for tpa and tenant id . Can you help us connect the same through active js tool

    TPA:- Lz0xbMj5+jmJF/r5yHtQzgom6D10NvEbjISdIMWjwnM=

    TenantID:- 1

  • Posted 9 September 2024, 7:38 am EST

    Hi Anju,

    Sure, please find attached a sample implementing the same.

    Regards,

    Anand

    SampleReport.zip

  • Posted 10 September 2024, 3:32 am EST - Updated 10 September 2024, 3:37 am EST

    Dear Team,

    we are running the same file but at our end we are not able to load data.

    Attaching the screenshots.

  • Posted 11 September 2024, 4:37 am EST - Updated 11 September 2024, 4:42 am EST

    Hi Anju,

    This error is due to CORS not being properly setup at the server end from where the data is being fetched, you can see the detailed error message when loading the report in an ActiveReportsJS viewer application and checking the Developer console (see attached image) I have also attached a sample for the same using your report.

    This error will go away if you either deploy the application to the same domain from where the request is being fetched or for development you can change the domain to a local server.

    As this is a generic issue unrelated to ActiveReports you may refer to Access to XMLHttpRequest at ‘…’ from origin ‘localhost:3000’ has been blocked by CORS policy.

    Regards,

    Anand

    ARJS_Viewer.zip

  • Posted 16 September 2024, 7:17 am EST - Updated 16 September 2024, 7:23 am EST

    Hi,

    We are now using a CORS enabled API. The issue is from calling the API from Active JS report tool it is unable to load the data from API. PFB screenshot for the same

    /

    But trying the same from designer component it is working fine.

    API details:-

    URL:-

    https://faw24.milessoft.com/V24_Main_DevQA/ClientPortalv24/24RestAPI/Client/Schemes

    Header:-

    ‘Content-Type’: ‘application/json’,

                    'TPA': 'Lz0xbMj5+jmJF/r5yHtQzgom6D10NvEbjISdIMWjwnM=',
    
                    'TenantId': '1'
    

    Post body:- 7joIb/20+DbhFriYaUuuh+2mh590bYwLC7IuVG/tXxTmV1rMaQfz4TcszVfWimzjIN9t9/ipMCFsKR8YK9xxn4jIHVH1qBqJFLbp/OoROtsz4eXzJmH4FBJCm/fccg9vEjpwhrCoH/vJT8oC/VZu7Hlip/7yNOaZNNbNzTm5TKLdE/ZQYIC99bDuPE7d/pPrNFsMY2rPYvYXOhBKjRATI4mvHHE0El6brPcIC/1zb34gPTJVGMH/y0h1nvhCGIPZhZCiS7bhy0XfHA7RJlBSpBPwU01l6hmK1R5lU8nhGBvFJwGezXBq2u5ClHgWYWyz8RCAq5a0QdBJSso7x1Ah/A==

  • Posted 16 September 2024, 7:17 am EST - Updated 16 September 2024, 7:23 am EST

    Hi,

    We are now using a CORS enabled API. The issue is from calling the API from Active JS report tool it is unable to load the data from API. PFB screenshot for the same

    /

    But trying the same from designer component it is working fine.

    API details:-

    URL:-

    https://faw24.milessoft.com/V24_Main_DevQA/ClientPortalv24/24RestAPI/Client/Schemes

    Header:-

    ‘Content-Type’: ‘application/json’,

                    'TPA': 'Lz0xbMj5+jmJF/r5yHtQzgom6D10NvEbjISdIMWjwnM=',
    
                    'TenantId': '1'
    

    Post body:- 7joIb/20+DbhFriYaUuuh+2mh590bYwLC7IuVG/tXxTmV1rMaQfz4TcszVfWimzjIN9t9/ipMCFsKR8YK9xxn4jIHVH1qBqJFLbp/OoROtsz4eXzJmH4FBJCm/fccg9vEjpwhrCoH/vJT8oC/VZu7Hlip/7yNOaZNNbNzTm5TKLdE/ZQYIC99bDuPE7d/pPrNFsMY2rPYvYXOhBKjRATI4mvHHE0El6brPcIC/1zb34gPTJVGMH/y0h1nvhCGIPZhZCiS7bhy0XfHA7RJlBSpBPwU01l6hmK1R5lU8nhGBvFJwGezXBq2u5ClHgWYWyz8RCAq5a0QdBJSso7x1Ah/A==

  • Posted 16 September 2024, 7:19 am EST

  • Posted 17 September 2024, 2:05 am EST - Updated 17 September 2024, 2:10 am EST

    Hi Sagar,

    We tried using a POST API from a public URL reqres.in by making a POST request at ‘https://reqres.in/api/users’ and it seems to work as expected with ActiveReportsJS.

    Please find attached a sample of the implementation of the same.

    To debug the cause of the issue we suggest using our attached sample with your report making a POST request and you can track any error logged in the developer console.

    Regards,

    Anand

    Viewer_React.zip

  • Posted 18 September 2024, 1:41 am EST

    The API we are using is working in designer component but the same is not working in Desktop tool.

    Also, can you provide us the steps to use the console.

  • Posted 19 September 2024, 5:42 am EST

    Hi Sagar,

    We tried using the Desktop Designer for ActiveReportsJS as well by making a POST request at ‘https://reqres.in/api/users’ and it seems to work as expected.

    Please refer to our attached video demonstrating the same.

    The Standalone designer i.e. the Desktop designer runs on Electron locally on your system (at localhost) because of which unfortunately you cannot open the Developer Console of the same.

    Regards,

    Anand

    ARJS_StandaloneDesigner_PostRequest.zip

  • Posted 24 September 2024, 1:30 am EST - Updated 24 September 2024, 1:35 am EST

    While using below Api in desktop designer it is not able to get data from Api. But the same Api is working in designer component. Can you give us specific RCA for this. Currently we are using the trial version license.

    API details:-

    https://faw24.milessoft.com/V24_Main_DevQA/ClientPortalv24/24RestAPI/Client/Schemes

    Header

    Content-Type’: ‘application/json’,

    ‘TPA’: ‘Lz0xbMj5+jmJF/r5yHtQzgom6D10NvEbjISdIMWjwnM=’,

    ‘TenantId’: ‘1’

    Post Body

    7joIb/20+DbhFriYaUuuh+2mh590bYwLC7IuVG/tXxTmV1rMaQfz4TcszVfWimzjIN9t9/ipMCFsKR8YK9xxn4jIHVH1qBqJFLbp/OoROtsz4eXzJmH4FBJCm/fccg9vEjpwhrCoH/vJT8oC/VZu7Hlip/7yNOaZNNbNzTm5TKLdE/ZQYIC99bDuPE7d/pPrNFsMY2rPYvYXOhBKjRATI4mvHHE0El6brPcIC/1zb34gPTJVGMH/y0h1nvhCGIPZhZCiS7bhy0XfHA7RJlBSpBPwU01l6hmK1R5lU8nhGBvFJwGezXBq2u5ClHgWYWyz8RCAq5a0QdBJSso7x1Ah/A==

  • Posted 25 September 2024, 8:05 am EST

    Hi Sagar,

    We tested your latest API ‘https://faw24.milessoft.com/V24_Main_DevQA/ClientPortalv24/24RestAPI/Client/Schemes’ in Desktop Designer as well as integrated Viewer component and it seems to work as expected in both scenarios.

    Please refer to our attached video demonstrating the same.

    Thanks,

    Anand

    CORS_Enabled_API.zip

  • Posted 4 October 2024, 1:44 am EST

    Hi,

    Thanks for the response it is working in our environment as well. Also as seen in the video in previous post you have embedded the JS reports as well. Can you share us a sample project to embed the JS report in .net for the same.

Need extra support?

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

Learn More

Forum Channels