my API dose not work on flutter and return 404 - android

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.

Related

Axios Network Error in React Native with Expo in Android

I'm trying to run an API call in React Native on Android with Expo using Axios, but I'm encountering a network error. I tried some solutions, but nothing seems to work. This is the error displayed in the console:
Network Error
at node_modules\\axios\\lib\\core\\AxiosError.js:3:0in \<global\>
at node_modules\\axios\\lib\\adapters\\xhr.js:138:8 in handleAbort
at node_modules\\event-target-shim\\dist\\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\\react-native\\Libraries\\Network\\XMLHttpRequest.js:647:10 in setReadyState
at node_modules\\react-native\\Libraries\\Network\\XMLHttpRequest.js:396:6 in didCompleteResponse
at node_modules\\react-native\\Libraries\\vendor\\emitter_EventEmitter.js:150:10 in EventEmitter#emit
at node_modules\\react-native\\Libraries\\BatchedBridge\\MessageQueue.js:417:4 in callFunction
at node_modules\\react-native\\Libraries\\BatchedBridge\\MessageQueue.js:114:6 in guard$argument_0
at node_modules\\react-native\\Libraries\\BatchedBridge\\MessageQueue.js:368:10 in guard
at node_modules\\react-native\\Libraries\\BatchedBridge\\MessageQueue.js:113:4 in callFunctionReturnFlushedQueue
I tried changing the localhost in the API link to my IP address, as well as to 10.0.2.2, but nothing worked. I checked my internet permission in AndroidManifest and made some other permission changes to the file, but nothing seemed to resolve it. I hope to find a solution to the problem soon.
if you are using a tool like expo go, [axiosError: Network error] is simply an error saying that the api you provided may not be reached.
so if you want to pull data from a local storage instead of cloud storage ... you may create a server like for example php artisan serve then create an Ngrok server for that server , afterwards take the link you received from the ngrok then use it as your new API endpoint
i m the same problem. you found solution l

How to view result from JSON API in browser

I have a JSON API URL "http://myurl/getDataMethod" this takes a parameter "parameter1". How can I call this API in browser to view its result? Can I use JSFiddle to see the result on runtime? If not then can you provide code for viewing the result in Android app?
I tried calling the API in android App but I got error java.io.FileNotFoundException:, I don;t know why. Also my parameter is having # symbol which is getting converted to %40 when I call the URL through code in APP. I just want to view the data from this API by passing parameter, please help/advise. Thanks.
You can always use an API Tester tool like Postman for testing/viewing the response received from an API. Also if your API method is GET, you can even use a browser by passing the relevant query parameters.
When you try to call an API from a browser, the entire URL gets Encoded so # becomes %40
Use Postman software to access your api and its data anytime before you start coding so as to know the data structure and flow.
Refer to the Postman tutorials or official documentation to learn more about the working
Postman documentation link:
https://learning.getpostman.com/docs/postman/api-documentation/documenting-your-api/

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.

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.

Consuming .net rest api via android - 400 error

I have created REST service according to this: http://www.asp.net/web-api/overview/older-versions/creating-a-web-api-that-supports-crud-operations
tutorial and a android client according to this: http://www.techrepublic.com/blog/software-engineer/calling-restful-services-from-your-android-app/
I changed the service to receive the json messages, and the connection string to the same that works in the browser, with 10.0.2.2 instead of localhost(according to one of the advices in stackoverflow) - in the browser it works perfectly. When I try to test it on the emulator I get the 400 bad request error. Maybe this is totally wrong way of approaching this, I am confused - would you kindly show me the error in the implementation or the tutorial that could help me with consuming the rest api with android client?

Categories

Resources