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”}