ESchouten
06/07/2023, 6:28 PM<http://client.post|client.post>(loginUrl) {
setBody(FormDataContent(Parameters.build {
append("username", username)
append("password", password)
append("submit", "Log in")
}))
}
This results in a successful login.
Now with Javascript I want to do the same:
fetch(loginUrl, {
method: 'POST',
headers:{
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
username,
password,
submit: 'Log in'
})
})
This does not result in a successful login.
Can anybody tell me how Ktor client handles this Form post different than JS does?Aleksei Tirman [JB]
06/08/2023, 9:54 AMESchouten
06/08/2023, 1:45 PMimport https from 'https'
const options = {
host,
path,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
const request = https.request(options)
request.write(Buffer.from(btoa(params.toString()), 'base64'))
request.end();