title: [Openstack]: Upload Image through API using cURL
body: <p>I have set up Openstack 4.0.2 (Train release). I'm trying to provide APIs to my client for building a web application. Everything works on the command line as well as on Horizon Dashboard. However, through API right from the token generation to flavor creation, server (VM) creation works except for Image Upload!</p>
  <p>Below is the cURL command for Token Generation:</p>
  <pre><code>export TOKEN=`curl --silent -X POST -H &quot;Content-Type: application/json&quot;   -d '{ &quot;auth&quot;: { &quot;identity&quot;: { &quot;methods&quot;: [&quot;password&quot;], &quot;password&quot;: { &quot;user&quot;: { &quot;name&quot;: &quot;admin&quot;, &quot;domain&quot;: { &quot;id&quot;: &quot;default&quot; }, &quot;password&quot;: &quot;MYPASS123&quot; }  } }, &quot;scope&quot;: { &quot;project&quot;: { &quot;name&quot;: &quot;admin&quot;, &quot;domain&quot;: { &quot;id&quot;: &quot;default&quot; } } } } }' -i &quot;http://controller:5000/v3/auth/tokens&quot; | grep X-Subject-Token | cut -d &quot;:&quot; -f 2`
  </code></pre>
  <p>The token is generated based on project scope.</p>
  <pre><code>echo $TOKEN
  gAAAAABh1tudXXtt............3J-1E3KCMR7tlq-gacOmo8
  </code></pre>
  <p>Below is the cURL command to create an Image</p>
  <pre><code>curl -X POST -s http://controller:8774/v2.1/servers -d '{&quot;server&quot;: { &quot;name&quot;: &quot;API1&quot;, &quot;imageRef&quot;:&quot;a62daa1b-2fba-47ad-8008-538cd88f306c&quot;, &quot;flavorRef&quot;:&quot;54eb939a-a39a-40ae-b50c-ed69b9f565ba &quot;, &quot;OS-DCF:diskConfig&quot;: &quot;AUTO&quot;, &quot;security_groups&quot;: [ { &quot;name&quot;: &quot;sg2&quot; } ], &quot;networks&quot;: [ { &quot;uuid&quot;: &quot;1c4d7023-4d3e-4d4a-aacc-deba1e9f9b98&quot; } ], &quot;user_data&quot;:&quot; I2Nsb3VkLWNvbmZpZwpwYXNzd29yZDogY2VudG9zCmNocGFzc3dkOiB7IGV4cGlyZTogRmFsc2UgfQpzc2hfcHdhdXRoOiBUcnVlCgo=&quot; }}' -H &quot;Content-Type: application/json&quot; -H &quot;X-Auth-Token: $TOKEN&quot; | python -m json.tool
  </code></pre>
  <p>glance-api.log</p>
  <pre><code>2022-01-05 14:08:09.687 26227 DEBUG eventlet.wsgi.server [-] (26227) accepted ('controller', 53108) server /usr/lib/python2.7/site-packages/eventlet/wsgi.py:985
  2022-01-05 14:08:09.695 26227 DEBUG glance.api.middleware.version_negotiation [-] Determining version of request: GET /v2/images Accept: */* process_request /usr/lib/python2.7/site-packages/glance/api/middleware/version_negotiation.py:45
  2022-01-05 14:08:09.697 26227 DEBUG glance.api.middleware.version_negotiation [-] Using url versioning process_request /usr/lib/python2.7/site-packages/glance/api/middleware/version_negotiation.py:57
  2022-01-05 14:08:09.699 26227 DEBUG glance.api.middleware.version_negotiation [-] Matched version: v2 process_request /usr/lib/python2.7/site-packages/glance/api/middleware/version_negotiation.py:69
  2022-01-05 14:08:09.700 26227 DEBUG glance.api.middleware.version_negotiation [-] new path /v2/images process_request /usr/lib/python2.7/site-packages/glance/api/middleware/version_negotiation.py:70
  2022-01-05 14:08:11.592 26227 WARNING keystonemiddleware.auth_token [-] Authorization failed for token: InvalidToken: Token authorization failed
  </code></pre>
  <p>Keystone.log</p>
  <pre><code>2022-01-05 14:08:11.584 492 WARNING keystone.server.flask.application [req-cecd6824-2faf-453b-8772-e2d0f67573c5 ba62aab1541c47fe8c59aeecb82c71d1 4d2a479d2d544c0c994bf55405f83d64 - default default] Could not recognize Fernet token: TokenNotFound: Could not recognize Fernet token
  </code></pre>
  <p>keystone.conf</p>
  <pre><code>[cache]
  memcache_servers = controller:11211
  
  [database]
  connection = mysql+pymysql://keystone:MYPASS123@controller/keystone
  
  [token]
  provider = fernet
  </code></pre>
  <p>glance-api.conf</p>
  <pre><code>[DEFAULT]
  bind_host = 0.0.0.0
  
  [database]
  connection = mysql+pymysql://glance:glancepass123@controller/glance
  
  [glance_store]
  stores = file,http
  default_store = file
  filesystem_store_datadir = /var/lib/glance/images/
  
  [keystone_authtoken]
  www_authenticate_uri = http://controller:5000
  auth_url = http://controller:5000
  memcached_servers = controller:11211
  auth_type = password
  project_domain_name = default
  user_domain_name = default
  project_name = service
  username = glance
  password = glance123
  
  [paste_deploy]
  flavor = keystone
  </code></pre>
  <p>glance policy.json</p>
  <pre><code>{
      &quot;context_is_admin&quot;:  &quot;role:admin&quot;,
      &quot;default&quot;: &quot;role:admin&quot;,
  
      &quot;add_image&quot;: &quot;role:admin&quot;,
      &quot;delete_image&quot;: &quot;role:admin&quot;,
      &quot;get_image&quot;: &quot;&quot;,
      &quot;get_images&quot;: &quot;&quot;,
      &quot;modify_image&quot;: &quot;&quot;,
      &quot;publicize_image&quot;: &quot;role:admin&quot;,
      &quot;communitize_image&quot;: &quot;&quot;,
      &quot;copy_from&quot;: &quot;&quot;,
  
      &quot;download_image&quot;: &quot;&quot;,
      &quot;upload_image&quot;: &quot;role:admin&quot;,
  
      &quot;delete_image_location&quot;: &quot;&quot;,
      &quot;get_image_location&quot;: &quot;&quot;,
      &quot;set_image_location&quot;: &quot;&quot;,
  
      &quot;add_member&quot;: &quot;&quot;,
      &quot;delete_member&quot;: &quot;&quot;,
      &quot;get_member&quot;: &quot;&quot;,
      &quot;get_members&quot;: &quot;&quot;,
      &quot;modify_member&quot;: &quot;&quot;,
  
      &quot;manage_image_cache&quot;: &quot;role:admin&quot;,
  
      &quot;get_task&quot;: &quot;&quot;,
      &quot;get_tasks&quot;: &quot;&quot;,
      &quot;add_task&quot;: &quot;&quot;,
      &quot;modify_task&quot;: &quot;&quot;,
      &quot;tasks_api_access&quot;: &quot;role:admin&quot;,
  
      &quot;deactivate&quot;: &quot;&quot;,
      &quot;reactivate&quot;: &quot;&quot;,
  
      &quot;get_metadef_namespace&quot;: &quot;&quot;,
      &quot;get_metadef_namespaces&quot;:&quot;&quot;,
      &quot;modify_metadef_namespace&quot;:&quot;&quot;,
      &quot;add_metadef_namespace&quot;:&quot;&quot;,
  
      &quot;get_metadef_object&quot;:&quot;&quot;,
      &quot;get_metadef_objects&quot;:&quot;&quot;,
      &quot;modify_metadef_object&quot;:&quot;&quot;,
      &quot;add_metadef_object&quot;:&quot;&quot;,
  
      &quot;list_metadef_resource_types&quot;:&quot;&quot;,
      &quot;get_metadef_resource_type&quot;:&quot;&quot;,
      &quot;add_metadef_resource_type_association&quot;:&quot;&quot;,
  
      &quot;get_metadef_property&quot;:&quot;&quot;,
      &quot;get_metadef_properties&quot;:&quot;&quot;,
      &quot;modify_metadef_property&quot;:&quot;&quot;,
      &quot;add_metadef_property&quot;:&quot;&quot;,
  
      &quot;get_metadef_tag&quot;:&quot;&quot;,
      &quot;get_metadef_tags&quot;:&quot;&quot;,
      &quot;modify_metadef_tag&quot;:&quot;&quot;,
      &quot;add_metadef_tag&quot;:&quot;&quot;,
      &quot;add_metadef_tags&quot;:&quot;&quot;
  }
  </code></pre>
  <p>Openstack role assignment list:</p>
  <pre><code>[root@controller glance]# openstack role assignment list --names --role admin
  +-------+-----------------------+-------+-----------------+---------+--------+-----------+
  | Role  | User                  | Group | Project         | Domain  | System | Inherited |
  +-------+-----------------------+-------+-----------------+---------+--------+-----------+
  | admin | neutron@Default       |       | service@Default |         |        | False     |
  | admin | cinder@Default        |       | service@Default |         |        | False     |
  | admin | admin@Default         |       | admin@Default   |         |        | False     |
  | admin | placement@Default     |       | service@Default |         |        | False     |
  | admin | glance@Default        |       | service@Default |         |        | False     |
  | admin | glance@Default        |       | admin@Default   |         |        | False     |
  | admin | nova@Default          |       | service@Default |         |        | False     |
  | admin | demouser@Default      |       | admin@Default   |         |        | False     |
  | admin | admin@Default         |       |                 |         | all    | False     |
  +-------+-----------------------+-------+-----------------+---------+--------+-----------+
  </code></pre>
  <p>Please help me to figure out what am I missing? Thanks in advance</p>