8

I am trying to use the NetSuite SuiteTalk REST Web Services to access NetSuite CRM data.

I have the access up and working in production. Able to retrieve record data and metadata.

I am now trying to set up access in the sandbox for more in-depth testing.

In the sandbox I have: - Enabled rest web services - Enabled token based authentication - Given user concurrent web services permission - Given user Log in using access tokens permission - Created an integration - Created an access token

All of these actions mirrored what was done in production.

When I attempt any kind of GET to the web service, I receive a 401 - Invalid login attempt.

When I check the Login Audit Trail, I don't see any record of the GET attempt, failed or otherwise.

Is there something of a systemic nature that I have to do additionally in the sandbox to enable rest web services? Above and beyond enabling it in SuiteCloud/SuiteTalk?

The fact that I see absolutely nothing in the audit trail makes me believe that something is still "turned off".

===> 4/4/2020 Update

ed14 and Nihkil,

Thank you for your responses, and sorry for the delay in responding back.

The hyphen to underscore in the realm did not help me unfortunately.

Let me recap recent attempts:

1) Started by verifying that REST API testing in production still works.

2) The sandbox was refreshed by a CRM admin. The application was still there, but my access token was not. I created a new one in the sandbox.

Is it possible to delete the application? I cannot see any way to do that.

3) Tested with existing Consumer Token and new Access Token. Got the same response as from my first post: "title": "Invalid login attempt, for more details see Login Audit Trail.",

4) Tested by slightly modifying the URL to make sure I was not going to a black hole somewhere. It gave me the expected error.

5) Tested by modifying the realm: Realm 9999999-sb4 to Realm 9999999_sb4 It gave me an error which leads me to believe that my original realm is correct: "title": "An unexpected error occurred. Error ID: k8hd8pqej3unxblmaoik",

Again, none of the tests show up in anywhere in the audit log as a failed attempt.

Not sure where to go from here? Delete the sandbox application (if possible) and start again? Or new application in sandbox?

Thanks for any and all help.

Bryan Hunt

Bryan Hunt
  • 145
  • 2
  • 5

4 Answers4

17

I had the same issue using the sandbox. Apparently there is a mismatch between the account ID (used in realm authorization) and the account ID in the URL.

The account ID (realm): XXXXX_SB1

The account ID in the url: XXXXX-SB1

The SB should be in upper case.

This solved the problem for me.

palhares
  • 1,663
  • 17
  • 13
ed14n
  • 171
  • 3
  • 1
    oh my gosh this fixed it. use dashed id for url, use underscore id for realm value, and it works! finally! – Josh Mar 27 '20 at 01:08
  • 1
    ed14n, Tested by modifying the realm: Realm 9999999-sb4 to Realm 9999999_sb4 It gave me an error which leads me to believe that my original realm is correct: "title": "An unexpected error occurred. Error ID: k8hd8pqej3unxblmaoik" – Bryan Hunt Apr 07 '20 at 23:36
  • 1
    OMG! Worked. @BryanHunt , the `SB` should be in upper case, or else it will return this error. Change the realm and url to uppercase. – palhares Apr 30 '20 at 22:01
5

As @ed14n and @nikhil-abraham said, changing - to _ in authorization realm and put the SB in UPPER CASE solve this problem here.

If you are using POSTMAN template provided from NetSuite, your envs should be like the image below.

Postman environments

palhares
  • 1,663
  • 17
  • 13
1

In Postman in your request tab and then in the authorization tab in the advanced section there is a field called Realm. Put the account id in the realm field with underscores.

0

I had the same error in my c# code ("{"error" : {"code" : "INVALID_LOGIN_ATTEMPT", "message" : "Invalid login attempt."}}").

I changed Realm(netsuiteAccountId) "xxxxxxx-sb1" change to "xxxxxxx_SB1". The _SB should be in upper case.

This is working fine for me.

        var consumer_key = "abcde12345";
        var consumer_secret = "12345abcde";
        var tkey = "1a2b3c4d5e";
        var token_secret = "a12b3c4d5e";
        var URL = "https://xxxxxxx-sb1.restlets.api.netsuite.com/xxx/site/hosting/xxx.nl?xxxx=xxxx&deploy=x";
       

        var client = new RestClient(URL);
        var oAuth1 = OAuth1Authenticator.ForAccessToken(
                        consumerKey: consumer_key,
                        consumerSecret: consumer_secret,
                        token: tkey,
                        tokenSecret: token_secret,
                        OAuthSignatureMethod.HmacSha256);

        var netsuiteAccount = "xxxxxxx_SB1"; // "xxxxxxx-sb1" change to "xxxxxxx_SB1"
        oAuth1.Realm = netsuiteAccount;

        client.Authenticator = oAuth1;
        var request = new RestRequest(URL, Method.POST);
        request.AddHeader("Content-Type", "application/json");
        string body = "{\"start\": {\"from\": 12345, \"to\": 67890 } ";
        request.AddParameter("application/json", body, ParameterType.RequestBody);
        var response = client.Execute(request);