netsuitesuitescriptsap-concur

nlapiRequestURL returning http code 400 Invalid parameter combination


I have a Netsuite scheduled script that connects to Concurs API to revoke all tokens for a user but I am getting a response code of 400 Invalid parameter combination. I have tried many different ways of setting the parameters but, I am having no luck.

Concur's Documentation says that this is what the need:

ConsumerKey: The access token of which you wish to revoke all current and future access. User: The login Id of the token owner. Format:

POST https://{InstanceURL}/net2/oauth2/revoketoken.ashx?consumerKey={Consumer Key}&user={User}
Authorization: OAuth {Token}

Here is my code

	var headers = {};
	headers['Content-Type'] = 'application/json';
	headers['Accept'] = 'application/json';
	headers['Authorization'] = 'Basic ' + credentials;
	headers['X-ConsumerKey'] = key; 
	headers.Authorization = 'OAuth ' + token;

	var urlpassed='revoketoken.ashx?consumerKey='+ key +'&user=WebAdmin%40redfin.com';
	var revokeToken = nlapiRequestURL('https://concursolutions.com/net2/oauth2/revoketoken.ashx?consumerKey='+ key +'&user='+ user,'', headers, 'POST');


Solution

  • As per Concur Docs you should add consumerKey and user as parameter as in the below code snippet:

    nlapiRequestURL('https://www.concursolutions.com/net2/oauth2/revoketoken.ashx?consumerKey='
        + YOUR_CONSUMER_KEY + '&user=' + YOUR_LOGIN_USER_ID, 
      '', 
      {'Authorization': 'OAuth ' + token}, 'POST');
    

    For the above code I got 200 OK in my case.