This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

How to connect to DPA API using Javascript Fetch

Version DPA 2022.2.7862

Attempting to use Javascript to connect to DPA using API Call. Keep getting error TypeError: Failed to fetch

Connection String is:

var rToken = '---------------------------------------------------------------------------------------------------------------------------------';

fetch('https://*************:****/iwc/api/security/oauth/token', {
method: 'POST',
body: 'grant_type=refresh_token&refresh_token='+rToken,
headers: {
}
}).then(function (resp) {
prompt(resp.statusTest);
}).then(function (data) {
prompt(data.data);
}).catch(function (err) {
prompt(err);
});

I am able to use PowerShell successfully using these parameters, but the HTML page throws an error when JavaScript is used

  • This seems like you're working on something awesome. Would love to see some of the PS if it's available, i've struggled with this in the past but havnt tried recently.

    Offhand i'm not seeing a fix yet, but I might need to work in this space fairly soon