question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid URI "/services/data/v36.0"

See original GitHub issue

Can Somebody explain me , why code 1 fails and gives error <Invalid URI “/services/data/v36.0” > while code 2 passes .

var conn1 = new jsforce.Connection({ oauth2: {

loginUrl: 'sandbox-login-url',
redirectUri: 'sandbox-login-url'

} });

Code 1 conn1.login(‘username’, ‘password’, function (err, userInfo) { if (err) { return console.error(err); } console.log("Org ID 1: " + userInfo.organizationId); });

conn1.identity(function (err, res) { if (err) { return console.error(err); } console.log("user ID conn1: " + res.user_id);

console.log("display name conn1 : " + res.display_name); });

Code 2 conn1.login(‘username’, ‘password’, function (err, userInfo) { if (err) { return console.error(err); } console.log("Org ID 1: " + userInfo.organizationId);

conn1.identity(function (err, res) { if (err) { return console.error(err); } console.log("user ID conn1: " + res.user_id);

console.log("display name conn1 : " + res.display_name); }); });

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
StingyJackcommented, Oct 31, 2016

@bityogi - using nodejs was only a fun project for me so I could maybe add another useful tool to my toolbox. However the requirement for even simpler javascript programs to be completely callback driven is just too much of a pain to deal with.

Frankly its stupid that the language/ide/environment (whatever of those node is) doesn’t provide a simple opt in/out, or at least is intelligent enough to understand that the program should block until it gets the result of a function when the next line depends on that result.

function myFunc(){
 var result = "do something that takes a while";
 return result;
}

var myFuncResult = myFunc();
if (myFuncResult != null)
{
    //node's impatience is vexing.
}
else
{
  // I would expect node to be smart enough to wait
}
2reactions
simonproovecommented, May 19, 2017

@shubhamr javascript runs asynchronously. In code1, if identity() call happens before login() is finished, you get ‘Invalid URI’ error. So running code1 you may see error messages (from calling identity()) before a successful "Org ID 1: " message. Code2, the block is in callback, thus has no problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 - Salesforce Stack Exchange
Salesforce API throwing error some times while creating accounts:-> Error: Invalid URI "/services/data/v36.0/sobjects/Account" ; – dsharrison.
Read more >
Ask Question - Stack Overflow
I am trying to get Account information from Salesforce using jsforce REST API, but I am getting ": Invalid URI ...
Read more >
Getting : Error: Invalid URI | Salesforce Trailblazer Community
I am using postman to make API calls. For that -- I did fork on Salesforce Api Platform collection but getting Invalid URI...
Read more >
A brand new website interface for an even better experience!
Invalid URI "/services/data/v36.0"
Read more >
REST API Developer Guide | Oregon.gov
When you include an invalid header value for If-Match, If-None-Match, ... "url" : "/services/data/v36.0/sobjects/Distributor__c/a03D0000003DUhcIAG".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found