question

pavan avatar image
pavan asked dnalor commented

TaxRate creation using rest api working on Clover mobile and mini but not on Clover station

here is the code i am using to create TaxRate the exception we are getting is **

Received non ok status from server HTTP/1.1 401 Unauthorized

**

CloverAuth.AuthResult authResult = CloverAuth.authenticate(selectFunction.this,account);

                if (authResult.authToken != null && authResult.baseUrl != null) {

                    CustomHttpClient httpClient = CustomHttpClient.getHttpClient();


                    String req=  "{ \"isDefault\": false,\"rate\": \"0\", \"name\": \"NoGiftTax\", \"id\": \"\", \"items\": [ { \"id\": \"\"}]}\"";

                    String urlNew=authResult.baseUrl+"/v3/merchants/"+authResult.merchantId+"/tax_rates";
                    String str= httpClient.post(urlNew,req,authResult.authToken);
                    srResponse=authResult.merchantId+"\n"+str;
                    if(str!=null && str.trim().length()>0)
                    {
                        JSONObject jsob=new JSONObject(str);
                        if(jsob!=null && jsob.has("id")) {
                            taxid = jsob.getString("id");
                        }

                    }

                }

// post method for web call

public String post(String url, String body,String apiToken) throws IOException, HttpException {
            String result;
            HttpPost request = new HttpPost(url);
            HttpEntity bodyEntity = new StringEntity(body);
            request.setEntity(bodyEntity);
            request.addHeader("Authorization","Bearer "+apiToken);
            request.setHeader("content-type", "application/json");

            HttpResponse response = execute(request);
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    result = EntityUtils.toString(entity);
                } else {
                    throw new HttpException("Received empty body from HTTP response");
                }
            } else {
                throw new HttpException("Received non-OK status from server: " + response.getStatusLine());
            }
            return result;
        }
10 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dnalor avatar image dnalor commented ·

Hi Pavan!

We also have the same problem when trying to post a payment on an open order. It is quite interesting because it works for us on the station and sandbox, but not on production mini.

I could get an error log out of it, for us it was this:

avax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x6c4171c0: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23GETSERVERHELLO:sslv3 alert handshake failure (external/openssl/ssl/s23clnt.c:744 0x684e2ce0:0x00000000)

Would be nice to get a solution for it.

0 Likes 0 ·
maninder avatar image maninder commented ·

hello Clover Team, My client is facing the same issue.

0 Likes 0 ·
maninder avatar image maninder commented ·

Hi @Dnalor. Is it happening randomly on any device or just the mini in your case ?

0 Likes 0 ·
dnalor avatar image dnalor commented ·

@maninder For me it's just the production Mini. It's working alright on prod Station and Sandbox Mini, so it's kind of strange.

0 Likes 0 ·
maninder avatar image maninder commented ·

@miguel, any idea about this issue ?

0 Likes 0 ·
Show more comments
sam avatar image
sam Deactivated answered sam Deactivated commented

The given error message:

Received non ok status from server HTTP/1.1 401 Unauthorized

is an indication that the given token is not a valid one.

It sounds like you're not receiving a valid token from your device due to the known issue we have when the app is uninstalled then installed. Please see this thread for the workaround until the fix, which is being rolled out as we speak:

https://devask.clover.com/question/65...

3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

pavan avatar image pavan commented ·

@Sam ok will try this but

CloverAuth.AuthResult authResult = CloverAuth.authenticate(selectFunction.this,account,true);

showing as deprecated and suggested to use

AuthResult authenticate(Activity activity, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit)

can you tell me which method should i use?

0 Likes 0 ·
sam avatar image sam commented ·

@Pavan Yes, please use

AuthResult authenticate(Activity activity, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit)

This will safely timeout instead of locking up.

0 Likes 0 ·
pavan avatar image pavan commented ·

@Sam yes we already used this and working on all devices, and i appreciate your help thanks :)

0 Likes 0 ·
dnalor avatar image
dnalor answered

Hi Pavan!

We also have the same problem when trying to post a payment on an open order. It is quite interesting because it works for us on the station and sandbox, but not on production mini.

I could get an error log out of it, for us it was this:

avax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x6c4171c0: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23GETSERVERHELLO:sslv3 alert handshake failure (external/openssl/ssl/s23clnt.c:744 0x684e2ce0:0x00000000)

Would be nice to get a solution for it.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community