Hi i'm wondering why my API call works in browser but when called in Android studio I get a 403 error. The Debug
D/OkHttp: <-- 403 https://api.boblop.com/search/api/rest/v3/catalog/products/search/keyword?q=asesea&key=esaesaesae (106ms)
D/OkHttp: server: AkamaiGHost
D/OkHttp: mime-version: 1.0
D/OkHttp: content-type: text/html
D/OkHttp: content-length: 350
D/OkHttp: expires: Tue, 20 Sep 2022 10:27:24 GMT
D/OkHttp: date: Tue, 20 Sep 2022 10:27:24 GMT
D/OkHttp: strict-transport-security: max-age=31536000 ; includeSubDomains
D/OkHttp: <HTML><HEAD>
D/OkHttp: <TITLE>Access Denied</TITLE>
D/OkHttp: </HEAD><BODY>
D/OkHttp: <H1>Access Denied</H1>
Any Ideas why android studio might be giving me back a 403 error?
Many Thanks
I just implement it in some code you can check it below:
request = new Request.Builder()
.url("https://api.johnlewis.com/search/api/rest/v2/catalog/products/search/keyword?q=dishwasher&key=AIzaSyDD_6O5gUgC4tRW5f9kxC0_76XRC8W7_mI")
.get()
.addHeader("Cache-Control","no-cache")
.addHeader("User-Agent",System.getProperty("http.agent"))
.build();
by using above code i am able to get 200 response in mobile app. i used OkttpClient for this just add header in retrofit to solve 403 issue.
Response{protocol=h2, code=200, message=, url=https://api.johnlewis.com/search/api/rest/v2/catalog/products/search/keyword?q=dishwasher&key=AIzaSyDD_6O5gUgC4tRW5f9kxC0_76XRC8W7_mI}