title: Creating a Google Sheets spreadsheet with developer metadata using the Sheets API
body: <p>I am interested in creating spreadsheets in Google Sheets programmatically. One of my requirements is that I will be able to write to and read from developer metadata associated with columns in the spreadsheet.</p>
  
  <p>I am currently having trouble with creating Developer Metadata - either spreadsheet-level or associated with a specific portion of the sheet. When I send the request to <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create" rel="nofollow noreferrer"><code>create</code></a> a new Spreadsheet, I am receiving a successful response, and the created spreadsheet's metadata object. However, the object that is returned from this request does not include any metadata objects (as the API documentation suggests).</p>
  
  <p>Setting an explicit metadata ID for the metadata entry and then attempting to retrieve it also does not appear to work (as you will see below).</p>
  
  <p>Here is the JSON payload I have been sending with the request (I have been sending the request using the <a href="https://developers.google.com/apis-explorer/#p/sheets/v4/" rel="nofollow noreferrer">Google APIs Explorer</a> most recently, as well, to isolate it from my code):</p>
  
  <pre><code>{
    "properties": {
      "title": "test 6:19 with sheet metadata"
    },
    "sheets": [
      {
        "properties": {
          "sheetId": 0,
          "title": "Sheet1",
          "index": 0,
          "sheetType": "GRID",
          "gridProperties": {
            "rowCount": 2,
            "columnCount": 2
          }
        },
        "data": [REMOVED_FOR_SPACE],
    "developerMetadata": [
      {
        "location": {
          "spreadsheet": true,
          "locationType": "SPREADSHEET"
        },
        "metadataKey": "questionId",
        "metadataValue": "12345",
        "visibility": "DOCUMENT",
        "metadataId": 12345
      }
    ]
  }
  </code></pre>
  
  <p>This request receives a 200, and returns a spreadsheet object that is missing any developer metadata, as mentioned before. The spreadsheet is created as described, and accessible via the UI. </p>
  
  <p>I suspected that the response may just not include the metadata, despite the documentation. However, if I query the spreadsheet for the metadata ID above, I receive the following response:</p>
  
  <pre><code>{
    "error": {
      "code": 404,
      "message": "No developer metadata with ID 12345.",
      "status": "NOT_FOUND"
    }
  }
  </code></pre>