Rest Assured - 404 when accessing localhost but accessible using Postman and browser - rest-assured

enter image description hereenter image description hereI get 404 when testing a GET api using Rest Assured on localhost developed using Spring boot Data JPA. However, On clicking the request url from Rest Assured logs it opens in browser.
The request works fine on Postman as well. However, cUrl code generated by Postman throws same error.
For Post request I get 403, Forbidden error in RA. works fine in Postman.

Related

Using Postman to test KOHA RestAPI but keep getting authentication failure

I have a problem working with Postman and Koha RestAPI to display desired input.
I want to try GET request on Postman using this URL as endpoint: https://{KOHADomain}/api/v1/patrons?userid={userid}.
What supposed to happen is the output should display all patrons detail in json or xml, but I keep getting this message:
{
"error": "Authentication failure."
}
The url works fine in the browser after login using KOHA privilege account. It displays all the desired output in xml form, but not in Postman.
The methods that I have tried:
Clear browser's cache.
Re-login Koha account.
Use Basic Auth.
Use OAuth 2.0. (client_id, secret_key, Token Access URL)
I really appreciate if someone could help me find the solution for this problem.

Receiving a "redirect_uri_mismatch" error when authorizing with OAUTH 2.0 only on mobile

here's a screenshot of the error
https://i.stack.imgur.com/m1DAp.jpg
here's a screenshot of OAuth client redirect uris and js origins
https://i.stack.imgur.com/5eBvs.png
on desktop everything works fine, problem is when i try to test it on a phone it shows me this error
request details says that i need to add https://main--rainbow-marzipan-5180d2.netlify.app/ to redirect uri , but its already there
ps: first post here be nice :D

404 when calling Imgur OAuth2 API

First attempt at using the Imgur API for OAuth2 authentication. I have a Client ID and Client Secret from https://api.imgur.com/oauth2/addclient. The URL that is being called from my Vue application looks like:
https://api.imgur.com/oath2/authorize?client_id={CLIENT_ID}&response_type=token&state=test
...where {CLIENT_ID} is the Client ID obtained from the client registration. This doesn't work from my web app and also fails in Postman. I'm getting back a 404 which displays the page that reads, "Zoinks! You've taken a wrong turn."
Any advice is appreciated.
I had the same problem. For me the solution was to open my Vue application from the network address https://192.168.2.100:8080 instead of the local adress https://localhost:8080
Vue console picture
Imgur apparently doesn't accept requests from localhost. Consequently I also had to set the OAuth2 redirect url of my application registered in imgur to http://192.168.2.100:8080/...

Getting HTTP 408 Request Timeout when submitting a POST request from Jenkins but the same is working fine using Postman

I'm calling an api (new relic insights api) and therefore using a HTTPs POST request (alongwith the required header) to call the api and run a NRQL query. Now, this POST request is working fine with Postman (or any other online tool for submitting https post request and I am getting the expected response as well, but when I try doing the same using HTTP Request Plugin in jenkins I am getting exceptions and errors as follows:-
class org.apache.http.conn.HttpHostConnectException(Connect to
insights-api.newrelic.com:443
[insights-api.newrelic.com/50.31.164.169,
insights-api.newrelic.com/50.31.164.210,
insights-api.newrelic.com/50.31.164.207,
insights-api.newrelic.com/50.31.164.208,
insights-api.newrelic.com/50.31.164.209] failed: Connection timed out:
connect) as 408 Request Timeout
The POST request is as follows:-
https://insights-api.newrelic.com/v1/accounts/******/query?nrql=SELECT%20count%28aonOperationNm%29%2C%20sum%28duration%29%2C%20average%28duration%29%2C%20min%28duration%29%2C%20max%28duration%29%2C%20percentile%28duration%2C%2090%29%2C%20percentile%28duration%2C%2095%29%2C%20percentile%28duration%2C%2099%29%20FROM%20Transaction%20WHERE%20appName%3D%20%27******%27%20FACET%20**************%20SINCE%20%272017-07-06%2007%3A33%3A00%20CDT%27%20UNTIL%20%272017-07-06%2008%3A07%3A00%20CDT%27%20limit%201000
and the associated header that I need to pass is:-
*X-Query-Key* - ***************************
(data masked with ******)
I'm able to get response for this using postman but not with jenkins. Also, the machine I'm trying connects to the internet via a corporate proxy which has been already configured in jenkins (Manage plugins - advanced), still getting http 408 error. What could I be missing?
Thanks in advance!
What happens when you issue a GET instead of a POST?
This Insights API example provided here via the New Relic docs uses a GET:
curl -H "Accept: application/json" -H "X-Query-Key: YOUR_QUERY_KEY" "https://insights-api.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/query?nrql=SELECT+count%28appName%29+FROM+PageView+SINCE+%272014-08-04+00%3A00%3A00%2B0500%27"

What can be done with following scenario for API Testing Automation?

I have to test rest api using rest assured API. The API is spring secured(Spring security mechanism is integrated by dev team for authentication). I am able to login using rest assured api and found the JSESSIONID also.
After successful login it send http status 302 means redirection and Cookie is found in Response headers which is used for further request.
Also when I press F12, the same APIs are hit with different HTTP status code. Requested URL : http://example.com/portal/home/xyz.html. One having status code 302 and other having status code 200.
Please see the image below: Headers information after pressing F12:
I am not able to redirect to the URL with the following code :
given().redirects().follow(false);
Check the documentation about the redirect following under the following link:
https://github.com/rest-assured/rest-assured/wiki/ReleaseNotes15

Resources