I have set up proper client credentials and access token with Oauth1.0 in my headers to authenticate using Token Based Authentication to my Netsuite Restlet but I am getting a 400 error response back:
error code: INVALID_REQUEST
error message: The request could not be understood by the server due to malformed syntax.
What do I need to change in my request to prevent this invalid request.
Here is my Module Spec in my RESTlet file:
/**
* @NApiVersion 2.1
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
If you still are having issues: I assume you are setting up your signature, with something like this for your normal requests and then using HMAC-SHA256:
data = $"oauth_consumer_key={config["consumerKey"]}" +
$"&oauth_nonce={oauthNonce}" +
$"&oauth_signature_method={config["signMethod"]}" +
$"&oauth_timestamp={timestamp}&oauth_token={config["tokenId"]}" +
$"&oauth_version={config["oauthVersion"]}";
When you hit a parameter endpoint for the restlet... something like: https://YOURACCOUNTID.restlets.api.netsuite.com/app/site/hosting/restlet.nl?scriptId=SCRIPTID&deployId=DEPLOYID you need to include those in the signature generation. They need to show up in alphabetical order too. so the above would change to:
data = $"deploy={deployNumber}" +
$"&oauth_consumer_key={config["consumerKey"]}" +
$"&oauth_nonce={oauthNonce}" +
$"&oauth_signature_method={config["signMethod"]}" +
$"&oauth_timestamp={timestamp}&oauth_token={config["tokenId"]}" +
$"&oauth_version={config["oauthVersion"]}&script={scriptId}";
Note you only pass the base script url without parameters when building the signature vaules and key:
var signatureValue = $"POST&Uri.EscapeDataString(https://YOURACCOUNTID.restlets.api.netsuite.com/app/site/hosting/restlet.nl)}&{Uri.EscapeDataString(data)}";
var signatureKey = $"{Uri.EscapeDataString(config["consumerSecret"])}&{Uri.EscapeDataString(config["tokenSecret"])}";
But you need to send the entire uri (with query parameters) in the post uri for your HttpRequestMessage.