Wednesday 30 September 2020

Why does this request return error 422?

I'm trying to run a request function to log into a website, in order to get the correct headers for the log in request I think i need to send a request to this uri: https://api.endclothing.com/tracker/rest/v1/gb/eventWhen i run this function i get a 422 error, I will put the Network request headers below:async function endTest() { const userPass = { username: "mygmail@gmail.com", password: "myPass" }; const createSession = async () => { console.log("create session"); const resp = await axiosInstance.post('https://api.endclothing.com/tracker/rest/v1/gb/event', { "application": "web", "currency": "GBP", "email": "mygmail@gmail.com", "email_hash_id": "email_f******************************a", "first_name": "jon", "language": "en", "last_name": "Doe", "origin": "account", "region": "GB", "shipping_country": "United Kingdom", "store_id": 1, "url": "https://www.endclothing.com/gb/" },{headers:{ 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8', 'content-type': 'application/json', 'origin': 'https://www.endclothing.com', 'referer': 'https://www.endclothing.com/', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36' }} ); const statusCode = resp.status; const cookieFirst = resp.headers["set-cookie"]; console.log(cookieFirst , statusCode); // axiosInstance.defaults.headers.Cookie = cookieFirst; // console.log('here'); } createSession(); Headers I send in the browser::authority: api.endclothing.com:method: POST:path: /tracker/rest/v1/gb/event:scheme: httpsaccept: */*accept-encoding: gzip, deflate, braccept-language: en-GB,en-US;q=0.9,en;q=0.8content-length: 346content-type: application/jsonorigin: https://www.endclothing.comreferer: https://www.endclothing.com/sec-fetch-dest: emptysec-fetch-mode: corssec-fetch-site: same-siteuser-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36​Data i send in the browser: {"event_name":"log_in","data":{"application":"web","currency":"GBP","email":"mygmail@gmail.com","email_hash_id":"email_f******************************a","first_name":"jon","language":"en","last_name":"doe","region":"GB","shipping_country":"United Kingdom","store_id":1,"url":"https://www.endclothing.com/gb/","origin":"account"}}Any idea's on how i can fix this?

Submitted September 30, 2020 at 03:56PM by Winner-Popular

No comments:

Post a Comment