How to define Square Version C#?

Hello,
My friends, forgive me if I am doing wrong. Trying to revoke access token using version 2022-02-16. It was working fine with version 2022-01-20.

Can someone tell me how to specify Square version when creating Square client using c# please?
Api explorer shows example for curl specifying version as ‘Square-Version: 2022-02-16’.
I could modify my code using curl but there are too many lines already in my code.
Below is my c# code specifying square version when creating client.

private SquareClient client;
this.client = new SquareClient.Builder()
.SquareVersion(“2022-01-20”) //<— Does not work.
.Environment(Program.squareproduction ? Square.Environment.Production : Square.Environment.Sandbox)
.AccessToken(Program.squareproduction ? Properties.Resources.squareAccessToken : Properties.Resources.squareAccessTokenSandbox)
.Build();

Using Properties.Resources value is OK in my case because this application is heavily obfuscated.

The problem is…
My code was working ok on version “2022-01-20” when revoking access token (sending merchant_id without access_token as guided by API document) but new version “2022-02-16” 's Revoke Token API does not work when merchant_id is provided without access_token for calling Revoke Token API. I think this is Square API error for the version “2022-02-16”.

I also tried API explorer with hard coded. Result is error. Error message is asking basically I need provide access token. API document and API explorer says ‘do not send access token when sending merchant id.’

I could just send merchant’s access token instead of merchant id. However, I need to know [How to specify Square Version in c#] in case Square API version updates.

Can someone answer this please?

Thanks,

:wave: The version for the SDK client should be set like:

Square.SquareClient client = new Square.SquareClient.Builder()
    .AccessToken("AccessToken")
    .SquareVersion(GetEnvironmentVariable("2022-02-16"))
    .Environment(Square.Environment.Production)
    .CustomUrl("https://connect.squareup.com")
    .HttpClientConfig(config => config.NumberOfRetries(0))
    .Build();

However I just tested revoking a token with the merchant_id and it worked as expected. What are your steps to reproduce and what’s the error you’re getting? :slightly_smiling_face:

Thank you for your response. I saved production merchant_id in database and then set my application as sandbox for testing and passed production merchant_id to revoke. This is my mistake.

API works fine. I apologize.

Glad to hear you figured it out. Feel free to reach out if you have any additional questions. :slightly_smiling_face: