Grandad, is that you?

Your browser is out of date and doesn't support all of the cool stuff we do on our website.

We like Google Chrome, but any modern browser will do.Update my browser now

×

Fetch a single project by UUID

Fetch a project that matches the given UUID. This is the code returned when the project is first inserted into the database via the add / update project call.

Resource URL

GET https://crowdsurfer.com/api/1.0/project/<UUID>/

Return

Success

HTTP 200

Returns the project matching that UUID.

HTTP 404: not found

No project was found with this UUID.

Example

Fetch a single project by UUID

:

Using the standard curl command:

curl -X GET \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Token abcdef123456890" \ https://crowdsurfer.com/api/1.0/project/platform-api-443-fe8ed292048a37163fc93124868eab3e/

We depend on the very useful requests library.

import requests import json r = requests.get('https://crowdsurfer.com/api/1.0/project/platform-api-443-fe8ed292048a37163fc93124868eab3e/', headers={'Authorization': 'Token abcdef123456890', 'Content-Type': 'application/json'}) print(r.json()) else: print("Failed: errors = %r" % r.json()['detail'])

Assumes that Guzzle has been installed using Composer.

require 'vendor/autoload.php'; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; $client = new GuzzleHttp\Client(); try { $response = $client->get('https://crowdsurfer.com/api/1.0/project/platform-api-443-fe8ed292048a37163fc93124868eab3e/', [ "headers" => [ "Accept" => "application/json", "Content-Type" => "application/json", "Authorization" => "Token abcdef123456890" ] ]); $json = $response->json(); var_dump($json); } catch (ClientException $e) { /* Failed uploads should return a "detail" dictionary describing the invalid fields: */ $errors = $json["detail"]; var_dump($errors); }

We use the Fluent API component of the Apache HttpComponents library.

Here's the Maven POM file:

4.0.0 crowdsurfer_post cspost 1.0-SNAPSHOT org.apache.httpcomponents httpclient 4.5 org.apache.httpcomponents fluent-hc 4.5

And here's the Java class:

package com.crowdsurfer.projects; import org.apache.http.client.fluent.Request; import java.io.IOException; public class ProjectFetcher { private String token; public final static String URL = "https://www.crowdsurfer.com/api/1.0/project/"; public ProjectFetcher(String apitoken) { token = apitoken; } public String get(String uuid) throws IOException { return Request.Get(URL+uuid+'/') .addHeader("Authorization", "Token "+token) .execute().returnContent().asString(); } public static void main(String[] args) { ProjectFetcher getter = new ProjectFetcher(args[0]); try { String response = getter.get(args[1]); System.out.println("GET succeeded: "+response); } catch (IOException e) { System.err.println("Failed to get resource: "+e); } } }