Error: read ECONNRESET && node js do not make any post request - api

i have this issue in my API my node js do not make any post request
that what is shown in console
GET /api/user 200 37.328 ms - 195
GET /api/user 200 5.662 ms - 195
POST /api/category - - ms - -
POST /api/user/register - - ms - -
POST /api/user/login - - ms - -
like you see the all request but in the POST is not working I have this issue in POSTMAN when I make a post request
I don`t think that issue is cuz of code cuz I have build many post request
when I make a restart that message shown in POSTMAN console
Error: read ECONNRESET
Request Headers
x-auth-token: this is my token
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Postman-Token: 2b4d5bc9-8bfc-4dc5-8608-24666dc5e754
Host: localhost:3000
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Related

Postman connect ECONNREFUSED 127.0.0.1:8080

Trying to test an API endpoint and got this error. Could it be my request body? Or is it a network issue? Maybe something I need to change in my proxy settings?
POST http://localhost:8080/v1/collections
Error: connect ECONNREFUSED 127.0.0.1:8080
Proxy
authenticate: false
disabled: false
host: "127.0.0.1"
id: "smth"
match: {…}
port: 8080
tunnel: false
Request Headers
Test: check-headers
x-ads-token-data: {stuff}
x-ads-gateway-secret: test1
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Postman-Token: xxxx
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
econnrefused means most probably you have not started your server on port 8080.
Take a look at the nodejs documentation here
ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
I am new to doing REST API and was trying to do Post request. I got this error when I was using Postman and c#
POST https://localhost:44310/api/Books
Error: connect ECONNREFUSED 127.0.0.1:44310
Request Headers
Content-Type: application/json
User-Agent: PostmanRuntime/7.28.4
Accept: */*
Host: localhost:44310
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Request Body
{
"Id": 1,
"Title": "Harry Potter",
"Author": "J.K. Rowling",
"Pages": 500
}
what happened was that the program was not running in visual studio but after executing it, the error did not appear again.
Hope my response will be useful.
I got the same issue and looks like clearing the breakpoints and setting the same again fixed the issue.
I was also suffering from the same problem. At that point in time, my local server was not published.
So I simply ran my backend server on IntelliJ IDEA.
Then try to post the request.
It works for me.
So, according to my experience, I would like to suggest that,
Before posting or getting any request you have to confirm that your local server is running properly.
I had the same problem and solved it by defining the "Edit / run configuration dialog" in IntelliJ

Postman shows "Could not get any response" even though response is OK

I have a WCF service which I make API requests to.
This API call returns a JSON response object and also is able to return it in GZIP compression as well when "gzip" value is used in "Accept-Encoding" header.
The problem is when I try to get the response in GZIP, Postman shows "Could not get any response" although I see response and response's content are OK (200 status code) in Fiddler and can easily decompress the response content in my C# client.
I took a look in Postman Console but all I see is "Error: incorrect header check".
I hardly tried to find any documentation regarding this header check but couldn't find any.
These are the request headers:
POST /correction/v1/document?lang=US HTTP/1.1
Content-Type: text/plain
Accept-Encoding: gzip
User-Agent: PostmanRuntime/7.6.0
Accept: */*
content-length: 630
Connection: close
These are the response headers:
HTTP/1.1 200 OK
Content-Length: 512
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 24 Feb 2019 14:05:50 GMT
Connection: close
The only thing I suspect is wrong is this message from Fiddler:
I integrated this code into mine in order to use GZIP in WCF.
https://github.com/carlosfigueira/WCFSamples/tree/master/MessageEncoder/GZipEncoderAndAutoFormatSelection
Basically, it captures the response before returning to client and use GZipStream for compression.
I got the same issue, I added the following header to fix this issue.
Accept-Encoding : *
I was able to solve a similar issue by using the header Accept-Encoding: */* or if you want to be specific do Accept-Encoding: */* that way the HTTP client will be able to process the response based on the type of encoding received, in the case of a gzip, it will decode the response and show it as normal text.
For me, I removed 'Accept-Encoding' in the request header.
I got this issue when the REST service was returning a zip content (aka. WinZip format). I solved the error by compressing the data using 7zip to produce true gzip format.

SQLMAP - Post JSON data as body

Hi I'm trying to do a SQL injection in a login form.
With BurpSuite I intercept the request:
POST /xxxx/web/Login HTTP/1.1
Host: 10.0.0.70:42020
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0
Accept: application/json, text/plain, */*
Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/json
Referer: http://xxxxxx.com/xxxxxx/
Content-Length: 44
origin: http://xxxxx.com
Connection: close
{"username”:"user",”password”:"pass"}
using:
sqlmap -u requestFile
(where requestFile is the content of the request intercepted with Burp)
sqlmap can't find the injectable field that is password.
I'm sure that's it's injectable cause if as password I input:
' OR 1=1; -- -
I can login with every username I insert
Tried also with:
{"username”:*,”password”:*}
but no luck.
What I'm doing wrong?
Example:
POST / HTTP/1.1
Host: www.example.com
{"username":"*", "password":"*"}
Saved as sqlrequest.txt
Can then initiate a test using this command:
py sqlmap.py -r sqlrequest.txt --level=5 risk=3 --force-ssl
You should then receive a prompt that a custom injection marker is found and that JSON data found in POST body. Process both and then you are good to go.
Sources:
https://security.stackexchange.com/a/150506/67046
https://security.stackexchange.com/a/51862/67046
sqlmap -u URL
sqlmap -r requestFile
Tutorial on how to use request
check this video

How Shockwave player generates HTTP POST request?

I am intercepting HTTP request/response from an Adobe Shockwave-based web music player application using Chrome Dev tools. When I click the Play button on music player, HTTP request headers like following are raised:
POST /some_url HTTP/1.1
Host: something.com
Connection: keep-alive
Content-Length: 103
Origin: http://something.com
X-Requested-With: ShockwaveFlash/22
User-Agent: Mozilla
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: http://something.com/player.swf
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
And Form data looks like following:
param1=561a0d9452069h76fhg46h67a599e8gy34nlj=
param2=something
Now, is there any way to know from where this param1=561a0d9452069h76fhg46h67a599e8gy34nlj= form data came from and how it is generated? If it's some kind of encrypted string or a token, how this is done?
Thank you for your answers
The HTTP request would have come from a URLRequest in ActionScript, which passes the data in key/value pairs. You could have a look at using SWFWire Inspector to decompile the code.

OAuth 1.0 to Oauth 2.0 Migration - "Invalid Token"

I'm Attempting to perform migration on user oauth 1.0 tokens to oauth 2.0 tokens, by following the steps described here.
Below is a sample of the call I'm making, redirected to my localhost.
POST / HTTP/1.1
Host: localhost:8080
Content-Length: 162
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.6.2 CPython/2.7.10 Darwin/14.1.0
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_nonce="52494019971914196991439415494", oauth_timestamp="1439415494", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="xxxxx.com", oauth_token="x%2Fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxx", oauth_signature="Da%2Bb0gFGyYT6AR2Xb5TAX5ynKQQ%3D"
client_secret=-FeCSEHzGADOt-3On5rE7Ghi&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Amigration%3Aoauth1&client_id=xxxxxxxxxxxxx.apps.googleusercontent.com
Every token I've tried returns a 400 error:
{ "error" : "invalid_token", "error_description" : "Either the token is invalid or we could not decode it." }
I've made this call using both requests-oauthlib and postman, with the same result.
Is there anything apparent I might be doing incorrectly?