Skip to content

Commit

Permalink
feat(test): post to license chula
Browse files Browse the repository at this point in the history
  • Loading branch information
tonklaw committed Aug 23, 2023
1 parent cc5195a commit eeac617
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,30 @@ async function run() {
password: core.getInput('cunet-password')
}

core.info(`Logging in with ${inputs.email}`)
const url = 'https://licenseportal.it.chula.ac.th'

// Create a HTTP client
const client = new httpm.HttpClient('cunet-login-action', [], {
allowRetries: true,
maxRetries: 3
})
core.info('Created HTTP client')

try {
let body = {
UserName: inputs.email,
Password: inputs.password
}
let res = await client.postJson(url, body)
core.info('POST request sent')

if (res.message.statusCode != 200) {
throw new Error(`Request failed with status code ${res.message.statusCode}`)
}

} catch (error) {
throw new Error(`failed to post to: ${error.message}`)
}

} catch (error) {
core.setFailed(error.message)
Expand Down

0 comments on commit eeac617

Please sign in to comment.