HTTP 403 Forbidden with android kotlin and retrofit - android

I'm working on sending data to an API and getting data back from it which is easy enough but how do i add api-key and client-id to my app (I'm using retrofit)? I tested it with Postman and it's working with both of them.

This is fixed by simply adding #Headers("key:value") above the GET/POST api call.
link to more info

Related

my API dose not work on flutter and return 404

Hi I training to work with API in flutter, my API work correctly on ASP.net mvc .net core and when I want signup user with postman everything work correct. but in flutter i get the 404 error. here this 3 images is my code. 1: api code. 2.flutter code. and the error 3.postman screenshot
how can I fix this?
1- Url, protocol type and port in postman different from in your code.
By the way when using HTTP,doesn't need to add 80 port in url "http://192.168.1.118:80".
2- Please check your parameter that isn't null or undefined.

API works in browser but not in postman or app

All the API's work in the browser but none of them is working in my android app and postman.
Status:
In postman and in my app, error code received is:
500 Internal Server Error
I think your problem is csrf-token you can disabled it in
App\Http\Middleware\VerifyCsrfToken
and add your routes name in this array
$except = [] array.
It could be that postman is missing some request headers, cookies or session data. You could look into using Postman Interceptor. It's a tool which records requests made from Google Chrome and clones them to your Postman history. From that history tab you can simply replay the request, which will be an exact clone. Maybe that'll resolve the 500 errors you're getting.

Android client consumes API returns bad request

I am currently learning django and android. I created a REST API for my backend. The endpoints are working since I can GET/POST with Postman, Insomnia, and httpie. However, if I try it with my android app it gives the response 'Bad Request'. I've been working on it for many hours now. Could someone explain to me why is this happening?
![1]: http://imgur.com/a/NF1oY
![2]: http://imgur.com/a/UG06U
Solved. I was using a lightweight server by django to run my api. Found out about gunicorn.

Jhipster Jwt Authentication for Mobile API

I have a jHipster project with Jwt Authentication but I can't get it to work outside de webapp. I'm currently developping a Android application and the authentication process get harder than I expected.
Basically I'm sending the parameters of the LoginDTO, to UserJwtController#authorize ('/api/authenticate'). At first I was getting Unauthorized, both on Android or Postman (I'm using it to test the requests).
If I change the '/api' to permitAll, I'm getting 405, Request method 'POST' not supported.
EDIT
It was a wrong typo on Android :/
It works fine for me against /api/authenticate, so either you use wrong URL (e.g. /api/authorize) or your JSON payload is wrong. The only issue you could have is with CORS. You should consider testing with curl as it is easier than PostMan for reporting here what you really do and also the curl options are already built for you in JHipster swagger page.

Calling Nest REST API on from android app without using Firebase SDK

Including Firebase.jar file in my android app project will cause reaching 64k dex limit. So, I'd like to use REST API instead of Firebase API.
After I got access token, I try to use either HttpPut or HttpsURLConnection to change thermostat mode. By using HttpsURLConnection, I got http response code 307 to ask me to redirect to firebase-apiserverN url. Then, I use the new URL and do a HttpsURLConnection PUT, I got http response code 400.
Is there any Nest API sample code for android without Firebase? Thanks.

Categories

Resources