Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1501

http request conversion from php to node

$
0
0

Im passing legacy php server to node. i have this php guzzle http request to some dashboard:

 $request = $this->http_client->request('POST',      $url,      [ 'headers' => ['Content-type: application/x-www-form-urlencoded'],'form_params' => ['authenticity_token'=> $authKey,'affiliate_user_session[login]'=>$this->partner->username,'affiliate_user_session[password]'=>$this->partner->password,'commit'=>'Log In to Portal'        ]      ]    );

it works correctly and i got back my response data.

but when Im trying to do same request in my node server i got error 422 - Unprocessable Entity, which as i understand imply that there is some syntactic error in the request.

the code in node axios:

const postResponse = await axios.post(                url,                {'authenticity_token': authKey,'affiliate_user_session[login]': name,'affiliate_user_session[password]': password,'commit': 'Log In to Portal',                },                {                    headers: {'Content-Type': 'application/x-www-form-urlencoded',                    }                }            );

the key, username, and password are the same.

so what is that syntactic error?

I got the same error when Im sending this request from postman.


Viewing all articles
Browse latest Browse all 1501

Trending Articles