Help with API login og password setting

Hi.
I need a nice person that will help med with the setting of my API for Billy.
I have the docs here Billy API v2 Documentation | Billy.dk
I am not sure where and how to enter my login and password. Can someone please help me out with the missing fields.
Am I missing out something, please let me know.
image

1 Like

Check out the node js section of code examples for the Billy api.

You will find

headers: {
                    'X-Access-Token': this.apiToken,
                    'Content-Type': 'application/json'
                },

This indicates the headers block should contain an object with 2 properties named X-Access-Token and Content-Type. Translating apis to Thunkable can be a challenge. Happy Thunking

Thanks for your fast reply. So nice of you.
I tryed this but it dont work, What am I doing wrong? Thanks
image

I now tryed this blocks
image
Headers text is : {ā€˜X-Access-Tokenā€™: f2361bb93689d15fd588e582e32c2xxxxxxxxxx,ā€˜Content-Typeā€™: ā€˜application/jsonā€™}

This blocks makes this errorā€¦

Put quotes around the token as well.

Also, quickly skimming the documentation, Iā€™m not sure if you can get the user info without an email and password. You might need to switch to a different command

@domhnallohanlon maybe you also can help with the blocks, please and thanks.

I have talked to their support and I just need the token. Is it JUST one place here ā€œINSERT ACCESS TOKEN HEREā€ I need it or every place written $accesToken???

He send me this example below. The last example is how to make anew contact. But I really cant see the block in front of me for this example. Do I need all of the below code or what??
Thanks a lot for your help.

//define a reusable class for sending requests to the Billyā€™s Billing API
class BillyClient {
private $accessToken;

public function __construct($accessToken) {
$this->accessToken = $accessToken;
}

public function request($method, $url, $body = null) {
    $headers = array("X-Access-Token: " . $this->accessToken);
    $c = curl_init("https://api.billysbilling.com/v2" . $url);
    curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    if ($body) {
        curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($body));
        $headers[] = "Content-Type: application/json");
    }
    curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
    $res = curl_exec($c);
    $body = json_decode($res);
    $info = curl_getinfo($c);
    return (object)array(
        'status' => $info['http_code'],
        'body' => $body
    );
}

}

$client = new BillyClient(ā€œINSERT ACCESS TOKEN HEREā€);

After this I can make a new contact with the following code:

//Create a contact
$res = $client->request(ā€œPOSTā€, ā€œ/contactsā€, array(
ā€˜contactā€™ => array(
ā€˜organizationIdā€™ => $organizationId,
ā€˜nameā€™ => ā€œArnoldā€,
ā€˜countryIdā€™ => ā€œDKā€
)
));
if ($res->status !== 200) {
echo ā€œSomething went wrong:\n\nā€;
print_r($res->body);
exit;
}

Hope you still wanna help. I found out I DONT need the mail and login. I just need the token.
I get this message back

400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.
The number of request header fields exceeds this server's limit.


Apache/2.4.18 (Ubuntu) Server at 172.17.0.11 Port 80

//-----------
With this blocks image

@domhnallohanlon hope you will give me a hint here. Thanksā€¦
The API docs is here billy-api-v2-docs.md Ā· GitHub

It looks like the header should be a JSON object with two properties X-Access-Token and Content-Type. You provided a string which is not formatted as JSON.

Smiling yes i am just trying something because it wont work like that either.
You mean lige this right???
image

Using blocks like this can eliminate problems with correctly formatting JSON.

3e753eb16c96506860c78e8ced05252ca0a20fc2

1 Like

THAT make sence THANKS. :grin:
But now I get a nother error like this.

{ā€œmetaā€:{ā€œstatusCodeā€:404,ā€œsuccessā€:false},ā€œerrorMessageā€:ā€œUnknown resource v2\/.ā€,ā€œerrorCodeā€:ā€œUNKNOWN_RESOURCEā€,ā€œhelpUrlā€:ā€œhttps://billysbilling.com/apiā€}

now I get this message. Like there is some authenticating missing
{ā€œmetaā€:{ā€œstatusCodeā€:401,ā€œsuccessā€:false},ā€œerrorMessageā€:ā€œInvalid OAuth 2 access token.ā€,ā€œerrorCodeā€:ā€œOAUTH_INVALID_ACCESS_TOKENā€,ā€œhelpUrlā€:ā€œhttps://billysbilling.com/apiā€}