createTransaction call failed with: 401

I can create UTXO addresses, Vault account, Vault account address, but when I try to create a transaction, I get

java.util.concurrent.ExecutionException: com.fireblocks.sdk.ApiException: createTransaction call failed with: 401 - {“message”:“Unauthorized: Token was not accepted.”,“code”:-7}

My user is of type ‘EDITOR’, I am using base url https://sandbox-api.fireblocks.io/v1 and the first 5 characters of my key are

MIIJR

What am I doing wrong ?

Thanks.

Hi @remicartier

An Editor can perform view-only queries, add wallets (except for wallets associated with SPL and ASA tokens), connect exchange accounts, create new vault addresses, and cancel transactions.

An Editor can only initiate transfers if you designate a signer for their transactions. Non-Signing Admins and Editors can initiate all transactions except internal exchange transfers.

Also if this is an NCW type transfer you will need an NCW Signer user. API Communication

Thank you @Mohammed for the quick response.

How do I do what you’re suggesting ?

I checked our transaction policy tab, and everything is greyed out. (Sandbox)

Thanks for your help.

Update 1: I created a new api user, with Non Signing Admin role, but I get the exact same error

Update 2: Our sandbox is ‘expired’, could that be an explanation ?

Hey Remi,
Apologies for the confusion, looks like it was actually an issue with the JWT, I am looking into it further.

This error code typically indicates theJWT supplied with the API user’s request was not accepted. API requests to Fireblocks are authenticated using the provided JWT.
Can you confirm if the body of your JWT follows this structure? Authenticate

@Mohammed I am using the Java SDK, I don’t manipulate the JWT.
Thanks.

@Mohammed Hi, not sure if you got the chance to check why my calls are failing, thanks.

Hi @remicartier I want to confirm if you are using this Java SDK and what version? Java SDK

@Mohammed

com.fireblocks.sdk:fireblocks-sdk:4.0.0

Update 1: I see that version 5.0.0 has been released, let me try with this one.

Update 2: It’s still not working

Exception in thread “main” java.util.concurrent.ExecutionException: com.fireblocks.sdk.ApiException: createTransaction call failed with: 401 - {“message”:“Unauthorized: Token was not accepted.”,“code”:-7}

Hi @remicartier thanks for the update, can you try to create a new API user and test this.

I also wanted to confirm if you are able to use any GET methods or if this error only occurs when creating TX.

The Token was not accepted error is usually an issue with the API user certificate or the JWT is not structured properly. And I understand you are not setting JWT(using Java SDK) So it could be error with the cert used to create that API user.

@Mohammed I tried with 2 api users, an EDITOR and a NON SIGNING ADMIN (thereis no global ADMIN role in sandbox it seems).

I can create vaults, addresses (2 POSTS requests).
I will find a GET request to test

I am not using any cert to create users, I just do it from the console. I downloaded the private key that was produced when generating the new user.

Does it help ?

Update 1: I can get the list of transactions with the same creds with which I can’t create a transaction

Update 2: We’re using Automated CSR as private key for the api user, so, if it’s broken, the sandbox is responsible of that

@Mohammed

Given that the highest access user in Sandbox is a “non-signin admin” which says it CANNOT create transactions, Could you at least confirm that creating Transactions is even possible via API in the Sandbox environment?

thanks.

Yes this is possible on Sandbox, apologize for any confusion but sandbox is confirmed operational and txs are working

@Mohammed
thank you for the response.
I tried again, to no avail.
What would you suggest me to try now ?
Do you think the ‘expired’ sandbox thing could be a problem ?
Should I create a new sandbox and try from there ?
thanks.

Hi @remicartier please send me your workspace name and first 4 digits of API key, the key you sent in original post was beginning of SecretKey

@Mohammed
Workspace name: Fiant - Luis Lopez
API Key first 4: 6b91
Thanks

2 Likes

Hi @remicartier our logs indicated your user with API key 6b91 is Non Signing Admin
:A user has failed to authorize Unauthorized: Token was not accepted.

I remember you stated this happened with your Editor user too, who should be able to execute transactions. I checked editor user fiant-dev and they too and I think I have found the solution!

You need to use editor user and when creating tx set xEndUserWalletId = null;
This seems to only occur with the JavaSDK, and I will try to document this,
:point_down:

@Mohammed
Thank you ! it’s working !
(Almost, it says there is not enough on the account to pay the fees, though I am not sure why. Trying to send 0.00001 BTC from 0.000465 BTC wallet. Do you know where I can see the fees it’s asking ?)

Update: I did a test with Solana and everything went well.

1 Like

So glad we were able to sort this out and thanks for your patience!! @remicartier

I had to do some digging into why this Java SDK required xEndUserWallet set to null even for non NCW transactions. We will be documenting this in the future!

1 Like