title: Invalid topicName does not match
body: <p>I have been trying to solve this problem all the day but I can't find where the error. I am making a program to detect when I receive an mail in my gmail and write that mail in a Google Spreadsheet, I am using the Gmail API and Google Apps Script. This is my code:</p>
  
  <p>gs code is :</p>
  
  <pre><code>function doPost(e) {
    var message = JSON.parse(e.postData.getDataAsString()).message
    var data = Utilities.newBlob(Utilies.base64Decode(message.data)).getDataAsString()[0];
    var ss = SpreadsheetApp.openById('1b8s5PLItCsmk8l1q0T1KHYOzjW7iDv4sRXSFvAxVFbQ').getSheets()[0];
    ss.appendRow([new Date(), message.message_id,data]);
    return 200;
  }
  
  function capturemail(){
  
    var WatchRes = Gmail.newWatchRequest();
    WatchRes.labelIds = ["INBOX"];
    //WatchRes.labelFilterAction = "include";
    WatchRes.topicName = "projects/proyecgmailyou/topics/mailsuc";
  
    var response = Gmail.Users.watch(WatchRes,"rjdelrio@uc.cl");
  
    Logger.log(response);
  
  }
  </code></pre>
  
  <p>The function doPost() I put in a web: <a href="https://script.google.com/a/uc.cl/macros/s/AKfycby8gOrWrMDkaAlgNdXNHl2J424Hvv0yu2CKKhJQW41Ka3Xa55g/exec" rel="noreferrer">https://script.google.com/a/uc.cl/macros/s/AKfycby8gOrWrMDkaAlgNdXNHl2J424Hvv0yu2CKKhJQW41Ka3Xa55g/exec</a> </p>
  
  <p>and then I try to run the function capturemail but appear the next error :</p>
  
  <pre><code>The API call to gmail.users.watch failed with the error: Invalid topicName does not match projects/sys-72285619869091378116913905/topics/* 
  </code></pre>
  
  <p>and is so strange because i never use this name"sys-72285619869091378116913905" and i didn t see it in same other place</p>
  
  <p>also i give the permission to gmail-api-push@system.gserviceaccount.com
  <a href="https://i.stack.imgur.com/4JyMs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4JyMs.png" alt="enter image description here"></a></p>
  
  <p>I think that the problem was the id of the project so I review that part and this is what I find:
  <a href="https://i.stack.imgur.com/4uwiP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4uwiP.png" alt="enter image description here"></a></p>
  
  <p>I also try to change the topicName for :</p>
  
  <pre><code>projects/sys-72285619869091378116913905/topics/mailsuc
  </code></pre>
  
  <p>but appear this other error:</p>
  
  <pre><code>The API call to gmail.users.watch failed with the error: Error sending test message to Cloud PubSub projects/sys-72285619869091378116913905/topics/mailsuc : Resource not found (resource=mailsuc).
  </code></pre>
  
  <p>however I am sure that I have that resource create because I did here:</p>
  
  <p><a href="https://i.stack.imgur.com/BCF5x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BCF5x.png" alt="enter image description here"></a></p>
  
  <p>and the last thing i used this video of youtube to guide me <a href="https://youtube.com/watch?v=wjHp9_NAEJo" rel="noreferrer">youtube.com/watch?v=wjHp9_NAEJo</a></p>