live_help Notes

assignment This action requires one of theses roles: Advanced tutor
group_work Requires following application scopes: projects
comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/project_data
{
  "project_data": {
    "by": "[[7, 3000, 1900, 3000, 1725], [36, 3000, 1725, 3100, 1725]]",
    "coordinates": "[2350.0, 3450.0]",
    "kind": "project",
    "project_session_id": "2"
  }
}
201
{
  "id": 9,
  "coordinates": [
    2350.0,
    3450.0
  ],
  "by": [
    [
      7,
      3000,
      1900,
      3000,
      1725
    ],
    [
      36,
      3000,
      1725,
      3100,
      1725
    ]
  ],
  "kind": "project",
  "project_session_id": 2
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"project_data":{"by":"[[7, 3000, 1900, 3000, 1725], [36, 3000, 1725, 3100, 1725]]","coordinates":"[2350.0, 3450.0]","kind":"project","project_session_id":"2"}}' "https://api.intra.42.fr/v2/project_data"

{
  "id": 9,
  "coordinates": [
    2350.0,
    3450.0
  ],
  "by": [
    [
      7,
      3000,
      1900,
      3000,
      1725
    ],
    [
      36,
      3000,
      1725,
      3100,
      1725
    ]
  ],
  "kind": "project",
  "project_session_id": 2
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token

params = {project_data: {by: "[[7, 3000, 1900, 3000, 1725], [36, 3000, 1725, 3100, 1725]]", coordinates: "[2350.0, 3450.0]", kind: "project", project_session_id: "2"}}
response = token.post("/v2/project_data", params: params)
response.status
# => 201
response.parsed
# => {"id"=>9, "coordinates"=>[2350.0, 3450.0], "by"=>[[7, 3000, 1900, 3000, 1725], [36, 3000, 1725, 3100, 1725]], "kind"=>"project", "project_session_id"=>2}