Setting up API communication by REST services with TerraIndex for customers - Download project attachments 

Page / - last modified by Robert Jan Daams on 2025/03/05 18:02 

Download project attachments 
last modified by Robert Jan Daams
on 2025/03/05 18:02

Table of Contents
Changelog
Update 2022-08-18
How to retrieve the list of available photo’s?
How to retreive the photo thumbnail?
How to retrieve the full size photo?

This page explains how to download a list of available photo’s for a project, and then how to really download that photo. Also a thumbnail is accessable, to prevent downloading full files.
Enthousiastic, read further…
Changelog
Update 2022-08-18
As part of on-going efforts to improve performance and scalabity, we have introduced a stand-alone media service (API).
We would kindly motivate you to switch to the new url's as soon as possible, so we can take advantage of the improvements.
 	URL	Example	
Old 	​https://web.terraindex.com/DataWS/ITWMediaRestService_V1_0	https://web.terraindex.com/DataWS/ITWMediaRestService_V1_0/GetMediaList	
New 	​https://web.terraindex.com/MediaWS/ITWMediaRestService_V1_0	https://web.terraindex.com/MediaWS/ITWMediaRestService_V1_0/GetMediaList	
How to retrieve the list of available photo’s?
For each project it’s possible to download the list of photo’s, we expose a REST service with JSON exchange objects. As long as you have the useraccount and the project GUID it’s possible to request it all.
This is the URL: https://web.terraindex.com/MediaWS/ITWMediaRestService_V1_0/GetMediaList
Method: POST
This is an example call:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
 "AuthorisationRequest": {
   "Username": "<yourUsername>",
   "Password": "<yourPW>",
   "Licensenumber": "<yourLicenseNumber>",
   "ApplicationCode": "<yourApplicationCode>"
  },
 "LanguageCode": "nld",
 "WebserviceVersion": "1.0",
 "MediaClassification": "ProjectPhoto",
 "Parameters": [
    {
     "ParameterType": "ProjectGuid",
     "StringValue": "<ProjectGUID>"
    }
  ]
}
•	Fill Username, Password, LicenseNumber and Application code with the provided information. For any other webservice this is already required to have, so reuse this information.
•	Language can be skipped, there are no translated items, so keep it ‘nld' or 'eng’.
•	Fill the ParameterType with ‘ProjectGuid' and fill the value in the StringValue.
•	The projectGUID can be found in the ProjectPreview webservice of in the dsFieldProject.xsd export in table: 'tblProjects’.
The response will be like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{
  "ResultCode": "GetMediaList_Success",
  "ResultMessage": null,
  "path": "/<licensenr>/<projectGUID>/Pictures",
  "files": [
    {
      "FileName": "aggregation querry.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "Capture.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "epic_prio.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "image.png",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "InkedWhatsApp Image 2018-06-26 at 15.53.55_LI.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "new icon.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "Redesign.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData+graph.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData+UniekUsrs+graph.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData+UniekUsrs+graph+errorcounter.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData+UniekUsrs+graph+errorcounter.png",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SavedTime+DailyData+UniekUsrs+graph+errorcounter_right.jpg",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "Sprint 3 vue app.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "SQLlite DB.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "Srpint 2.png",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "Srpint 3.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    },
    {
      "FileName": "taart.PNG",
      "Thumbnail_Base64": null,
      "File_Base64": null
    }
  ]
}
As you can see there is a list with photo’s with the name filled, but without the Thumbnail and the File.
These can be requested with the next 2 calls.
If there are no photo’s in the directory, or the directory isn’t even created. The Resultcode of the response will tell you 'the path is not found'. Meaning, no photo is ever created for this project.
How to retreive the photo thumbnail?
This is the URL: https://web.terraindex.com/MediaWS/ITWMediaRestService_V1_0/DownloadMediaThumbnail
Method: POST
This is an example call:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "AuthorisationRequest": {
    "Username": "<yourUsername>",
    "Password": "<yourPW>",
    "Licensenumber": "<yourLicenseNumber>",
    "ApplicationCode": "<yourApplicationCode>"
  },
  "LanguageCode": "nld",
  "WebserviceVersion": "1.0",
  "MediaClassification": "ProjectPhoto",
  "Parameters": [
    {
      "ParameterType": "ProjectGuid",
      "StringValue": "<ProjectGUID>"
    },
    {
      "ParameterType": "Filename",
      "StringValue": "aggregation querry.PNG"
    }
  ]
}
See the addition parameter with ParameterType = 'Filename' and the StringValue is the filename from the earlier request.
This is an example result:
1
2
3
4
5
6
{
  "ResultCode": "Download_Succes",
  "ResultMessage": null,
  "FileContent": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoG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QBIkh2vwnGP4B7+3tVOZi1xKSBlgc4AHYflRRQBehkLXEmVjxs6eWuBgn2qPzCD0Tnk5Qc8fSiigB3nsV+7Hzyf3a/4VVu5CURcKAD2UDtRRQBLGxQqQF4iUcqD6+vf3qYt/osA2pymD8g5xxz60UUANEzZ6R85/5Zr/hTxMzrIWWIlRx+6Xjn6UUUAUbty7IDt4B6KB39qkvGL3cZJ6DAxwPvY6CiigD/2Q==",
  "DownloadLog": null
}
The FileContent is now the Thumbnail, as Base64 string. Just convert this to a Byte[] with a default function:
Convert.FromBase64String(result.FileContent);
How to retrieve the full size photo?
Same call as the Thumbnail but only a different URL to call.
This is the URL: https://web.terraindex.com/MediaWS/ITWMediaRestService_V1_0/DownloadMedia
Method: POST
This is an example call:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "AuthorisationRequest": {
    "Username": "<yourUsername>",
    "Password": "<yourPW>",
    "Licensenumber": "<yourLicenseNumber>",
    "ApplicationCode": "<yourApplicationCode>"
  },
  "LanguageCode": "nld",
  "WebserviceVersion": "1.0",
  "MediaClassification": "ProjectPhoto",
  "Parameters": [
    {
      "ParameterType": "ProjectGuid",
      "StringValue": "<ProjectGUID>"
    },
    {
      "ParameterType": "Filename",
      "StringValue": "aggregation querry.PNG"
    }
  ],
  "UseZipstream": "false"
}
See the addition parameter with ParameterType = 'Filename' and the StringValue is the filename from the earlier request.
This is an example result:
{
  "ResultCode": "Download_Succes",
  "ResultMessage": null,
  "FileContent": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAADAQADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAA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4iUcqD6+vf3qYt/osA2pymD8g5xxz60UUANEzZ6R85/5Zr/hTxMzrIWWIlRx+6Xjn6UUUAUbty7IDt4B6KB39qkvGL3cZJ6DAxwPvY6CiigD/2Q==",
  "DownloadLog": null
}
The FileContent is now the FullImage, as Base64 string. Just convert this to a Byte[] with a default function:
Convert.FromBase64String(result.FileContent);
When 'UseZipstream' is True; the content will be extra Compressed and then converted to Base64 string. This way, first decode to Byte[], Inflate (GZipStream) and then write to file or use it.
*For images this is useless action, because images are already stored best compressed in the file format, so use this for the attachment like KML files (plain xml, perfect compressable))*