4

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

asked 2017-05-03 10:15:36 -0500

Pavan gravatar image

updated 2017-05-04 09:48:02 -0500

Comments
1

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.

Dnalor gravatar image
Dnalor 2017-05-03 10:36:37 -0500
1

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

maninder gravatar image
maninder 2017-05-03 10:40:10 -0500
1

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

maninder gravatar image
maninder 2017-05-03 11:18:23 -0500
1

@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.

Dnalor gravatar image
Dnalor 2017-05-03 11:31:49 -0500

@miguel, any idea about this issue ?

maninder gravatar image
maninder 2017-05-04 12:08:57 -0500

1 answer

Sort by  
2

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...

answered 2017-05-04 14:09:02 -0500

Sam gravatar image

updated 2017-05-04 14:09:40 -0500

Comments

@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?

Pavan gravatar image
Pavan 2017-05-05 03:32:41 -0500

@Pavan Yes, please use

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

This will safely timeout instead of locking up.

Sam gravatar image
Sam 2017-05-05 13:25:15 -0500

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

Pavan gravatar image
Pavan 2017-05-06 01:33:28 -0500