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