How to run a post request to an API from an HTML page (using a button linked to javascript code) when the API require certificate and user/password?

I want to add some javascript code into a HTML page that allow any user (with access to that web page) to run some post requests available there to an API. These post requests run well in Postman but I’m not sure how can I run this kind of requests using javascript since this API requires not only a certificate (with a passphrase) but also an additional credential pair (username and password) which in Postman are configured in a very intuitive way on the appropriate menus.

I’ve the following javascript code where I deal with the username and password but I don’t know how to dealt with the certificate/passphrase:

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Basic 123xpto321");

var raw = JSON.stringify({
  "path": "/Customers/Organisation/organisation_adm/Account Management/Account Balance/Accounts",
  "outputType": "pdf"

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'

fetch("https://api.url/my-endpoint", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Can someone help me on how I can pass the certificate to reach this API from an ordinary web page?

Thanks in advance!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.