Design: Where to find File IDs for Mutations

Modified on Thu, 14 Sep, 2023 at 2:08 PM

Why do I need a file ID?


Using mutationsyou can make edits to your design data with the Nexar API, such as adding a comment, uploading a new project or releasing a component.  

Sometimes, in addition to primitive inputs (strings, integers, etc...) these can require fileIds.  For example the mutation to release a component:

mutation desReleaseComponent(...) { }


makes use of the following input structure:

input DesReleaseComponentFileInput {
  "Uploaded file ID."
  fileId: String!
  "Relative path of the source file."
  relativePath: String!
}

Nexar's RESTful files service allows files to be uploaded for a short period of time (usually 1 day) and will return a "fileId" which can be used in this and other mutations. The API will then access the file and process it - in this case using it as part of the release component.

It's important to note that the file upload will require the same access token as the API for user authorization.  Since we need to know the user this token cannot be a Client Credentials token and should be generated for a specific user, e.g. with the Authorization Code  flow, such as via the Nexar Portal. 


How do I get a file ID?

Nexar's files service URL endpoint at: https://files.nexar.com and files can be uploaded to this using a standard multi-part form HTML post, for example:

curl --location --request POST 'https://files.nexar.com/File/Upload' \
--header 'token: <your access token> ' \
--form 'footprintFiles=@"/C:/Files/componentFootprintFiles.zip"

This will return the ID - such as c0d314e5-6d87-45e0-b4a3-9c17b0d2d20a - which can be used in the mutation itself:


mutation ReleaseComponent {
  desReleaseComponent(
    input: {
      footprintFiles: [
        { fileId: "c0d314e5-6d87-45e0-b4a3-9c17b0d2d20a", ... }
      ]
      ...
    }
  ) {
    errors {
      message
    }
  }
}


And finally...

We have a WPF example for releasing a component here:

https://github.com/NexarDeveloper/nexar-release-component-demo-wpf 



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article