|
The Projects Create API can be used to create a new project in the ClimateScan database. It also allows for adding pictures or research files to existing projects.
|
|
The Projects Create API can be used to create a new project in the ClimateScan database. It also allows for adding pictures or research files to existing projects.
|
|
|
|
|
|
Authorization for this endpoint is required. Please refer to the User Login API for more information on providing authorization data.
|
|
Authorization for this endpoint is required. Please refer to the User Login API for more information on providing authorization data.
|
|
|
|
|
|
| Attribute | Value |
|
|
| Attribute | Value |
|
|
| --- | --- |
|
|
|-----------|-------|
|
|
| URL | https://www.climatescan.org/api/v1/projects/new |
|
|
| URL | https://www.climatescan.org/api/v1/projects/new |
|
|
| Supported methods | `POST` |
|
|
| Supported methods | `POST` |
|
|
| Authorization required | Yes |
|
|
| Authorization required | Yes |
|
... | @@ -16,23 +15,27 @@ A request to the Project Create API must include the `Authorization` header. Bas |
... | @@ -16,23 +15,27 @@ A request to the Project Create API must include the `Authorization` header. Bas |
|
Additionally, a mix of form data and JSON structured data must be provided as the request body. To support file uploads, we require you to post formdata to this API. The structured JSON information can be included in the `params` formdata field.
|
|
Additionally, a mix of form data and JSON structured data must be provided as the request body. To support file uploads, we require you to post formdata to this API. The structured JSON information can be included in the `params` formdata field.
|
|
|
|
|
|
Below you will find a table documenting all supported formdata fields.
|
|
Below you will find a table documenting all supported formdata fields.
|
|
|
|
|
|
| Field | Type | Description | Example value |
|
|
| Field | Type | Description | Example value |
|
|
| ----------- | --------- | ------------------------- | ------------- |
|
|
|-------|------|-------------|---------------|
|
|
| `files[]` | `Blob` | This field only allows for uploading pictures. All entries are treated as images. This means that thumbnails are generated for each entry, and each entry is appended to the project as a picture. Non-image files are ignored and may be rejected. Please note that you may provide multiple images by providing this field multiple times. | No example. |
|
|
| `files\[\]` | `Blob` | This field only allows for uploading pictures. All entries are treated as images. This means that thumbnails are generated for each entry, and each entry is appended to the project as a picture. Non-image files are ignored and may be rejected. Please note that you may provide multiple images by providing this field multiple times. | No example. |
|
|
| `research[]` | `Blob` | This field only allows for uploading research files. The input files do not get processed and are saved as raw files to the project. Anyone can upload research files using this API. Only users with the Research role are currently able to download the uploaded files from the website. Please note that you may provide multiple files by providing this field multiple times. Please take care of providing a useful and unique filename for each file uploaded. | No example. |
|
|
| `research\[\]` | `Blob` | This field only allows for uploading research files. The input files do not get processed and are saved as raw files to the project. Anyone can upload research files using this API. Only users with the Research role are currently able to download the uploaded files from the website. Please note that you may provide multiple files by providing this field multiple times. Please take care of providing a useful and unique filename for each file uploaded. | No example. |
|
|
| `params` | `JSON` | This field is used to provide structured JSON data describing the project. Please refer to the JSON documentation below for more information. | No example. |
|
|
| `params` | `JSON` | This field is used to provide structured JSON data describing the project. Please refer to the JSON documentation below for more information. | No example. |
|
|
|
|
|
|
The `params` field must be provided with JSON-encoded information about the project. Below you will find a table documenting all supported JSON fields.
|
|
The `params` field must be provided with JSON-encoded information about the project. Below you will find a table documenting all supported JSON fields.
|
|
|
|
|
|
| Field | Type | Description | Example value |
|
|
| Field | Type | Description | Example value |
|
|
| ----------- | --------- | ------------------------- | ------------- |
|
|
|-------|------|-------------|---------------|
|
|
| `projectId` | `int` | Optional ID of an existing project. If this field is provided, the system will look up the existing project and append the `files[]` and `research[]` files to the existing project. No other existing data will be updated. | `"1"` |
|
|
| `projectId` | `int` | Optional ID of an existing project. If this field is provided, the system will look up the existing project and append the `files\[\]` and `research\[\]` files to the existing project. No other existing data will be updated. | `"1"` |
|
|
| `latitude` | `Decimal` | Latitude of the user's location. Due to legacy app support, this field is always required, even if updating an existing project. Existing project locations are never updated by this field. | `"53.1886"` |
|
|
| `latitude` | `Decimal` | Latitude of the user's location. Due to legacy app support, this field is always required, even if updating an existing project. Existing project locations are never updated by this field. | `"53.1886"` |
|
|
| `longitude` | `Decimal` | Longitude of the user's location. Due to legacy app support, this field is always required, even if updating an existing project. Existing project locations are never updated by this field. | `"6.95661"` |
|
|
| `longitude` | `Decimal` | Longitude of the user's location. Due to legacy app support, this field is always required, even if updating an existing project. Existing project locations are never updated by this field. | `"6.95661"` |
|
|
| `title` | `str` | Title of the project. This field is only required when creating new projects. It is ignored for existing projects. | `"Groen dak ziekenhuis Ommelander"` |
|
|
| `title` | `str` | Title of the project. This field is only required when creating new projects. It is ignored for existing projects. | `"Groen dak ziekenhuis Ommelander"` |
|
|
| `category` | `int` | ID of an existing category. This field is only required when creating new projects. It is ignored for existing projects. | `"116"` |
|
|
| `category` | `int` | ID of an existing category. This field is only required when creating new projects. It is ignored for existing projects. | `"116"` |
|
|
| `description` | `str` | Description text of the project. This field is only required when creating new projects. It is ignored for existing projects. | `"Lorem ipsum dolor iset amet.\nNew lines are also supported."` |
|
|
| `description` | `str` | Description text of the project. This field is only required when creating new projects. It is ignored for existing projects. | `"Lorem ipsum dolor iset amet.\\nNew lines are also supported."` |
|
|
|
|
|
|
|
|
You can use `params` to add additional information about research files. You should add an array to the `research` field, following the same order as when adding the research file entries.
|
|
|
|
| Field | Type | Description | Example value |
|
|
|
|
|-------|------|-------------|---------------|
|
|
|
|
| `public` | `bool` | Specifies whether the file can be downloaded by non-research users. | `true` |
|
|
|
|
| `contentType` | `str` | Specifies the content type. | `application/vnd.poll-data.v1+json` |
|
|
|
|
|
|
For example, the following JavaScript example could be used to create a new project.
|
|
For example, the following JavaScript example could be used to create a new project.
|
|
|
|
|
... | @@ -52,6 +55,14 @@ const jsonParams = { |
... | @@ -52,6 +55,14 @@ const jsonParams = { |
|
title: "Groen dak ziekenhuis Ommelander",
|
|
title: "Groen dak ziekenhuis Ommelander",
|
|
category: "117",
|
|
category: "117",
|
|
description: "This is an example project created by the API.",
|
|
description: "This is an example project created by the API.",
|
|
|
|
|
|
|
|
// The following fields describe the research files
|
|
|
|
research: [
|
|
|
|
{
|
|
|
|
public: true,
|
|
|
|
contentType: "text/plain",
|
|
|
|
},
|
|
|
|
],
|
|
};
|
|
};
|
|
|
|
|
|
// Now create the encapsulating formdata. We'll set the JSON params
|
|
// Now create the encapsulating formdata. We'll set the JSON params
|
... | @@ -108,11 +119,10 @@ await fetch('https://www.climatescan.org/api/v1/projects/new', { |
... | @@ -108,11 +119,10 @@ await fetch('https://www.climatescan.org/api/v1/projects/new', { |
|
The Projects Create API may return a 200 OK-response when a new project was created, or an existing project has been updated. Errors are being reported back by a 400 Bad Request-response.
|
|
The Projects Create API may return a 200 OK-response when a new project was created, or an existing project has been updated. Errors are being reported back by a 400 Bad Request-response.
|
|
|
|
|
|
The response is structured as follows.
|
|
The response is structured as follows.
|
|
|
|
|
|
| Attribute | Type | Description | Example value |
|
|
| Attribute | Type | Description | Example value |
|
|
| --------- | ---- | ----------- | ------------- |
|
|
|-----------|------|-------------|---------------|
|
|
| `success` | `str` | Status message if the project was created or updated successfully. This key is only available in 200 OK-responses. | `"The project has been updated!"` |
|
|
| `success` | `str` | Status message if the project was created or updated successfully. This key is only available in 200 OK-responses. | `"The project has been updated!"` |
|
|
| `errors` | `array[str]` | A list of errors encountered while creating or updating a project. This key is only available in 400 Bad Request-responses. | `["Title must be set", "Description must be set"]` |
|
|
| `errors` | `array\[str\]` | A list of errors encountered while creating or updating a project. This key is only available in 400 Bad Request-responses. | `\["Title must be set", "Description must be set"\]` |
|
|
|
|
|
|
Example successful response:
|
|
Example successful response:
|
|
|
|
|
... | | ... | |