How to call a endpoint in chatscript using header with basic authorization and ^jsonopen

45 Views Asked by At

I'm trying to do a calling to the endpoint that its written below but I don't know if I'm making the call correctly in the header.

I need to do a basic authorization with base64 encoded user and password credentials to call a fastapi endpoint but returns a 401 authorization error so i think maybe the header it's poorly structured but I'm not sure.

`u: ( !$obbdatos )

  • $_endpoint = ^"http://localhost:8000/example/exampleprueba"

$_header = ^"~Accept: application/json ~Authorization: Basic dXN1YXJpbzE6dXN1YXJpbzE= "

$_name = ^"elias"

$_url = ^join($_endpoint ? name = $_name)

$$data = ^jsonopen(GET $_url "" $_header)

$$data = ^jsonparse(transient NOFAIL $$data )

$nombre = $$data.name

Here I am simply passing the value of elias to the name parameter so that it returns elias since when I enter a name for that endpoint it returns the values of the registry with the name entered and I want to assign it to the variable $name so that I can use that value in my chatscript topics`

0

There are 0 best solutions below