Postman testing
WHEN VISUAL STUDIO RUNS API,
Look at browser it starts up and note the URL address and specifically the port such as: https://localhost:52334/ . Your local environment will need to match this.
LOCAL TESTING - COMMON PROBLEMS:
1) Must run the API in VS when do Postman so it will process. Breakpoints will work.
Failure to run is error: connect ECONNREFUSED 127.0.0.1:5212 .
2) Make empty body of { } . Exception is when the endpoint needs data.
Example error is "No MediaTypeFormatter is available to read an object of type 'InputData'." when it wants InputData.
3) Controller's method's attribute signature such as: [HttpPost("pricing/sellingprices")]
should match Postman request: POST {{BaseUrl}}/notify/
Example error is "405 Method Not Allowed".
4) Controller's method's [FromBody] parameter means you should have something
in the Body of the Postman call instead of only relying on URL parameters. See number 2 above.
5) If controller's method's attribute signature is: [Produces("application/json")]
Postman's inner tab of "Body", click "Raw" and "choose JSON".
6) Ensure Environment variables have been set and truly pointing to Local.
{{BaseUrl}}/pricechange/latest
So verify by replacing BaseUrl and braces with actual value such as: https://localhost:5212
7) String values should be enclosed with parathesises " " characters like "0".
Error is "The JSON value could not be converted to System.String."...
8) Make sure you are hitting http without the "s" on local testing, otherwise you get Error of:
write EPROTO 52680328
9) Apparently there are instances where you need https with the "s" on local testing, otherwise you get Error of:
socket hang up
10) "Unsupported media type" error - you probably are not supplying the [FromBody] contents.
DEV TESTING
Overall Postman:
Postman changes the URL on the fly as the parameters change.
Teams using Postman
Use Collections to share things
Comments
Post a Comment