0

I am using a Visual Studio 2010 WebForm application to post a simple note to EverNote using the sample code for "Hello world. Here is the Code:

    private void btnSubmit_Click(object sender, EventArgs e)
    {
       ENNote myPlainNote = new ENNote();
       ENSession.SetSharedSessionDeveloperToken(
       "My Developer 
       Token","https://www.evernote.com/shard/s308/notestore");
       myPlainNote.Title = "My First Notes";
       myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello 
       World!);
      ENNoteRef myPlainNoteRef = 
      ENSession.SharedSession.UploadNote(myPlainNote, null);
    }

I get "Object reference not set to an instance of an object" on the last line. I would really appreciate if someone could guide this newbie to resolve this issue.

  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Yuval Itzchakov Apr 26 '17 at 10:34
  • Just an update. I replaced the Developer Token line with ENSession.SetSharedSessionConsumerKey("my key", "my secret"); Now the application runs without error but no notes exists when I point my browser to https://sandbox.evernote.com. – Bamann Casmaii Apr 26 '17 at 14:22

1 Answers1

0

UploadNote requires a second parameter to indicate in which notebook you want the new note created.

You can pass it an ENNotebook; for example, you could get such an object like this:

List<ENNotebook> myNotebookList = ENSession.SharedSession.ListNotebooks();
ENNotebook desiredNotebook = myNotebookList.Find(i => i.Name == "The name of my desired notebook"); 

You should also be able to pass a second parameter of null to add the note to your default notebook.

Phil Seeman
  • 397
  • 3
  • 11
  • Thanks for your reply. I found out the problem was to do with the firewall or proxy server at work. Tried at home and it worked. This is a show stopper for me as the application is work related. – Bamann Casmaii May 04 '17 at 07:33