REST API: Trails/Images

This endpoint deals with images for a trail. Use PUT to update an image. The Set has GET and POST. PUT and POST require Oauth, GET requires an API key only.

Uploading is a two step process:
First, post the image to the Set

POST /Trails/6683560/Images/
The POST will return the new imageID, which should then be used in a PUT on the image:
PUT /Trails/6683560/Images/26620
Note after you upload an image, it will still not show in the list of trail images, because it will have a status of pending until RTC staff reviews it. However, you can still view it using the image handler:
http://www.traillink.com/imagehandler.ashx?id={imageID}&t={type}

{type} can be "sm" for a thumbnail, "150" for a 150px square thumbnail, "md" for a 300px image, "640" for a 640px medium-large or lg for full size

Resource URI

V1/Trails/6683560/Images/26620

Resource Properties

Parameter

Format

Description

Allows Null

caption string Cpation for the image no 
detailUrl  string  Formatted traillink url for trail  no 
displayName  string  User name for submitter  no 
imageID  long  unique identifier for image  no 
lat  decimal  Latitude for image.  0 if unknown  no 
lon  decimal  Longitude for image.  0 if unknown  no 
mimeType string  mime type for image.  no 
postDate  date  Date image was posted  no 
submitterAcctID  long  unique id for submitter  no 
title  string  Title for the image  no 
trailID  long  Unique ID for trail  no 
trailName  string  Name of trail  no 

Error Responses

HTTP PUT

Update image details. If the image that was POSTed had coordinates embedded in the exif then we will already have extracted them, so just leave them blank here.

This is just updating the details. Use POST on the Set to upload the actual image file.

Requires OAuth.

JSON Request:

{
"caption": "This is my new caption",
"detailUrl": "trail-name-test-2",
"displayName": "johnqsample",
"imageID": 26620,
"lat": "-74.32",
"lon": "40.52777777777780",
"mimeType": "image\/jpeg",
"postDate": "2013-03-28 04:00:00Z",
"submitterAcctID": 7440532,
"title": "This is the title",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}

JSON Response:

true

XML Request:

<TrailImageDetails>
<addUser>WEBSITE</addUser>
<caption> </caption>
<detailUrl>trail-name-test-2</detailUrl>
<displayName>egolde</displayName>
<email>egolde@gmail.com</email>
<imageID>26620</imageID>
<lat>-74.32</lat>
<lon>40.52777777777780</lon>
<mimeType>image/png</mimeType>
<postDate>2011-10-04T13:37:13</postDate>
<submitterAcctID>0</submitterAcctID>
<title>Middlesex Greenway</title>
<trailID>6683560</trailID>
<trailName>Trail Name Test 2</trailName>
</TrailImageDetails>

XML Response:

<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>

REST API: Trails/Images Set

The Set of images for a trail.  Use GET to get the trail's images.  Use POST to upload a new image.

Resource URI

/Trails/6683560/Images/?api_key=xxx

Set Filters

ParameterFormatDescriptionAllows Null
None      

HTTP GET

Get the set of images for the arg trail. This is just the details. To view the file, get
http://www.traillink.com/imagehandler.ashx?id={imageID}&t={type}
{type} can be "sm" for a thumbnail, "md" for a 300px image, or lg for full size

JSON Request:

request body empty

JSON Response:

[{
"caption": "This is my caption",
"detailUrl": "trail-name-test-2",
"displayName": "johnqsample",
"imageID": 26620,
"lat": "-74.32",
"lon": "40.52777777777780",
"mimeType": "image\/jpeg",
"postDate": "2011-10-04 17:37:13Z",
"submitterAcctID": 7440532,
"title": "This is the title",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}, {
"caption": "Similkameen River Bridge",
"detailUrl": "trail-name-test-2",
"displayName": "striker",
"imageID": 22344,
"lat": "-119.466604",
"lon": "48.950050",
"mimeType": "image\/png",
"postDate": "2010-09-21 16:31:45Z",
"submitterAcctID": 6263848,
"title": "Similkameen Trail",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}, {
"caption": " ",
"detailUrl": "trail-name-test-2",
"displayName": "RTC",
"imageID": 17706,
"lat": "0",
"lon": "0",
"mimeType": "image\/png",
"postDate": "2009-04-23 14:42:59Z",
"submitterAcctID": 6312099,
"title": " ",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}, {
"caption": "Between 96th and 125th Streets.",
"detailUrl": "trail-name-test-2",
"displayName": "railtrailbiker",
"imageID": 419,
"lat": "0",
"lon": "0",
"mimeType": "image\/jpeg",
"postDate": "2003-06-28 04:00:00Z",
"submitterAcctID": 4380721,
"title": "Hudson River Greenway",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}]

XML Request:

request body empty

XML Response:

<ArrayOfTrailImageDetails
xmlns="http://schemas.datacontract.org/2004/07/traillinkws.winfundsonline.com"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<TrailImageDetails>
<addUser>WEBSITE</addUser>
<caption> </caption>
<detailUrl>trail-name-test-2</detailUrl>
<displayName>egolde</displayName>
<email>egolde@gmail.com</email>
<imageID>26620</imageID>
<lat>-74.32</lat>
<lon>40.52777777777780</lon>
<mimeType>image/png</mimeType>
<postDate>2011-10-04T13:37:13</postDate>
<submitterAcctID>0</submitterAcctID>
<title>Middlesex Greenway</title>
<trailID>6683560</trailID>
<trailName>Trail Name Test 2</trailName>
</TrailImageDetails></ArrayOfTrailImageDetails>

HTTP POST

Upload a new image for a trail. The Content-Type of your request should be the image's mime type. The body should be the image's byte stream. If the image exif contains coordinates we will automatically extract them and add them to the image details.

We will return the new ImageID. Once the image has been POSTed, you must call PUT on the imageID with to update the image details.

Image rules: Max file size is 8MB
file types are: jpg, gif, png, & bmp
title and caption are max 256 characters

JSON Request:

The Request body is a byte stream

JSON Response:

5678

XML Request:

The Request body is a byte stream

XML Response:

<long xmlns="http://schemas.microsoft.com/2003/10/Serialization/">5678</long>