Showing posts with label postman. Show all posts
Showing posts with label postman. Show all posts

Tuesday, June 12, 2018

Make Postman test - Grails

Leave a Comment

I have the following test of a grails integration:

def http = new HTTPBuilder(loginUrl) http.request( POST, TEXT ) {     headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'     send URLENC, [j_username: username, j_password: password]      response.success = { resp, reader ->         loggedIn = ! reader.text.contains("j_username")     } } 

I'm trying to mount the test in Postman, but I'm not sure if I'm doing it correctly because of this send URLENC, [j_username: username, j_password: password]

I put the POST type route, and put something like:

{     j_username: username,     j_password: password } 

And the headers parameters:

'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4' 'Content-type' = 'Application/json' 

But it is always returning my login form in the body, does anyone know how to mount this test?

UPDATE

Actually in other projects I follow the reference and it works well. However I have developed the grails response part, did not leave an api/login route, and I believe that the login is done by the same web route /login/auth, but I can not validate the test by postman, but on the web logo perfectly.

UPDATE 2

I believe that in the project that receives my login request, to try to facilitate, they have made access to the api by the same web, and this request that is mounted in the integration, do not make a json type request, because of "send URLENC", Can someone please explain to me how to put this call in postman?

1 Answers

Answers 1

If you have the default Spring Security and Spring Security REST config, here how I do it :

Body of the Postman call

Header of the Postman call

Read More

Monday, March 19, 2018

POSTMAN sync not working behind a network proxy

Leave a Comment

I'm running POSTMAN sync (sync data across devices) behind a network proxy and it is not working. Apparently it's not honoring the global proxy configuration in my system. Login in and upload is working fine. Only the sync has the issue. I'm using Ubuntu 14.04 LTS 64bit Chrome Version 47.0.2526.106 (64-bit) Postman version 3.2.9

I have also tried restarting and reinstalling POSTMAN with no luck.

1 Answers

Answers 1

The most likely cause is that your proxy does not allow websocket connections that Postman sync uses for data synchronization. Check for error messages in Postman's DevTools window

Here is a good description of how to debug this issue.

Read More

Sunday, February 11, 2018

Retrofit - Different API responses on different devices

Leave a Comment

The problem exactly like the following I have one api which can provide some data and one apk,

I got my api response with my device and another different old response on the emulator with the same apk!

The emulator response is up to date with the latest changes while the other different response is before the changes.

The app uses retrofit without caching. So what could be the problem?

Request contains only one header (access token) Response contains headers like (ETag, Access-Control-Max-Age) but retrofit should not deal with them as there is no cache at all.

Screen shot from postman : enter image description here

Also when waiting for a while all devices become up to date!

2 Answers

Answers 1

Are you sure with this?

The app uses retrofit without caching

Based on this https://github.com/square/retrofit/issues/678, I think that retrofit (OkHttp inside retrofit) caching your query.

You can change this behavior by 2 ways:

  • add ?_t=TIMESTAMP into your app query url
  • remove 'Access-Control-Max-Age' header from your server response

Answers 2

Or you can create new OkHttp client to retrofit and write something like that:

new OkHttpClient.Builder().cache(null).build(); 

or

Request.cacheControl(CacheControl.FORCE_NETWORK) 
Read More

Monday, October 16, 2017

Unable to trigger web request implemented in Giraffe

Leave a Comment

I'm struggling to trigger a web service that's written in Giraffe.

Here's the code:

let webApp : HttpContext -> HttpHandlerResult =       choose [         GET >=>             choose [ routef "/platforms/" fetchPlatforms ] 

fetchPlatforms is implemented as follows:

let private fetchPlatforms () (context : HttpContext) =     async { let response = getPlatforms()             return! json response context     } 

The issue that I'm running into is that when I run the server code and then attempt to test the web service, I get the following message:

enter image description here

Here's the entire solution.

Update:

I am only observing this issue in VS Code.

Hence, I can observe a successful web request and response using Visual Studio 2017 (3) version 15.4

Here's the video that demonstrates the difference between VS2017 and VS Code

2 Answers

Answers 1

I downloaded your source code and tried to reproduce the issue, but first I was getting an error during startup because I don't have your db configured locally, therefore I made the following change:

type TestObj =     {         Prop1 : string         Prop2 : int     }  let private fetchPlatforms  =     let obj1 = { Prop1 = "test"; Prop2 = 100 }     json obj1     //  let response = getPlatforms()     //  json response 

... and when I start the app now and make a Postman call to the /platforms endpoint then it seems to work fine for me...

postman

Have you resolved your issue perhaps?

Answers 2

routef should match pattern: https://github.com/dustinmoris/Giraffe#routef

otherwise try route:

let webApp : HttpContext -> HttpHandlerResult =   choose [     GET >=>         choose [ route "/platforms" >=> fetchPlatforms ] 

EDIT:

And looking at your code, the fetchPlatforms function is not a proper handler. HttpHandler :

A HttpHandler is a simple function which takes two curried arguments, a HttpFunc and a HttpContext, and returns a HttpContext (wrapped in an option and Task workflow) when finished.

Instead of:

let private fetchPlatforms  =      let response = getPlatforms()      json response 

Try something like that:

let fetchPlatforms   =     fun (next : HttpFunc) (ctx : HttpContext) ->         let response = getPlatforms()         json response next ctx 

You can do that async as well (it depends on getPlatforms):

let fetchPlatforms   =     fun (next : HttpFunc) (ctx : HttpContext) ->         task {             let! response = getPlatforms()             return! json response next ctx         } 
Read More

Friday, October 6, 2017

Postman is not using cookie

Leave a Comment

I've been using Postman in my app development for some time and never had any issues. I typically use it with Google Chrome while I debug my ASP.NET API code.

About a month or so ago, I started having problems where Postman doesn't seem to send the cookie my site issued.

Through Fiddler, I inspect the call I'm making to my API and see that Postman is NOT sending the cookie issued by my API app. It's sending other cookies but not the one it is supposed to send -- see below:

enter image description here

Under "Cookies", I do see the cookie I issue i.e. .AspNetCore.mysite_cookie -- see below:

enter image description here

Any idea why this might be happening?

P.S. I think this issue started after I made some changes to my code to name my cookie. My API app uses social authentication and I decided to name both cookies i.e. the one I receive from Facebook/Google/LinkedIn once the user is authenticated and the one I issue to authenticated users. I call the cookie I get from social sites social_auth_cookie and the one I issue is named mysite_cookie. I think this has something to do with this issue I'm having.

1 Answers

Answers 1

I have been running into this issue recently with ASP.NET core 2.0. ASP.NET Core 1.1 however seems to be working just fine and the cookies are getting set in Postman

Read More

Thursday, August 3, 2017

My web api gives net:: ERR_CONNECTION_RESET error only from ajax client

Leave a Comment

My web api was working in several IISs and when moved to Azure VM, it gives net:: ERR_CONNECTION_RESET when calling only from ajax client but works proper when using POSTMAN.

When hitting from ajax html client it says net:: ERR_CONNECTION_RESET in OPTIONS request. Thought that it didnt reach the server but when referring http error file in

C:\Windows\System32\LogFiles\HTTPERR

It shows

2017-07-20 12:54:06 210.18.173.26 54141 10.0.1.4 80 HTTP/1.1 OPTIONS /api/User/Method1 - 1 Request_Cancelled myappapipool

In web.config

 <add name="Access-Control-Allow-Origin" value="*" />  <add name="Access-Control-Allow-Headers" value="Content-Type" />  <add name="Access-Control-Allow-Credentials" value="true" />  <add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" /> 

I have tried adding timeout in web.config, it is not solving. Also tried changing the web config "Access-Control-Allow-Headers" value to "*", it gave preflight request error.

Since the same server and ajax client communication is working in other iis, i suspect there is something fishy which i missing while configuring my web api in IIS which is located in Azure VM. When calling from POSTMAN or android client it is working like a charm with the existing configuration in IIS.

Any help/suggestion is much appreciated.

4 Answers

Answers 1

Request_Cancelled Coming in HTTPErr log is caused by the DynamicIPRestrictions Module mitigating against DDOS attacks.

if you setup Dynamic IP Restrictions with "Deny Action Type" set to "Abort Request", the requests will be aborted and logged as "Request_Cancelled" in the HTTPErr log

By default Dynamic IP Address Restrictions may abort the request if more than 5 concurrent requests come(check what is the configured setting in your server.) And that may be reason why it works for one server and does not work in Azure environment.More details can be found on Security guidelines to detect and prevent DOS attacks targeting IIS/Azure Web Role (PAAS)

Answers 2

What kind of error in browser's console do you see? Have a look on request/response header values IN the browser. Sometimes the configuration is not applied correctly and/or browser expects other headers. Sometimes, Allow-Headers param is too restrictive, try to play with that.

Also, is it reproducible on all browsers?

Answers 3

This is my web config configuration, working for both postman and chrome, you can give it a try:

<system.web>     <compilation debug="true" targetFramework="4.5.2" />     <httpRuntime targetFramework="4.5.2" />     <httpModules>       <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />     </httpModules>   </system.web>   <system.webServer>     <handlers>       <remove name="WebDAV" />       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />       <remove name="OPTIONSVerbHandler" />       <remove name="TRACEVerbHandler" />       <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />     </handlers>     <validation validateIntegratedModeConfiguration="false" />     <modules runAllManagedModulesForAllRequests="true">       <remove name="WebDAVModule" />       <remove name="ApplicationInsightsWebTracking" />       <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />     </modules>     <httpProtocol>       <customHeaders>         <add name="Access-Control-Allow-Origin" value="*" />         <add name="Access-Control-Allow-Headers" value="Content-Type" />         <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />       </customHeaders>     </httpProtocol>   </system.webServer> 

Hope it helps !

Answers 4

You will get this issue due to several reasons. But in this case, I assume that you have install WebDAV and sometimes it make conflict with other modules. So, you better to try to remove that extension first.

enter image description here

Read More

Thursday, June 9, 2016

How to use postman API client with openchain API server

Leave a Comment

I have just installed openchain (http://openchain.org)

I can check it on http://nossl.wallet.openchain.org/ but I would like to check API using Postman Rest client tool on my PC.

I'm using postman rest client and I have tried URI many times but response is empty : https://docs.openchain.org/en/latest/api/method-calls.html

Please give some advises, thanks in advance !

0 Answers

Read More