Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info

Developers please use

Newwindowlink
titlehttps://api-stage.bimplus.net/v2
urlhttps://api-stage.bimplus.net/v2
(stage version of Bimplus API) and
Newwindowlink
titlehttp://portal-stage.bimplus.net/
urlhttp://portal-stage.bimplus.net/
(stage version of Shop/Portal) for testing purposes. The production version of the portal is located under 
Newwindowlink
titlehttps://portal.bimplus.net/
urlhttps://portal.bimplus.net/
  and the base url of the API is different for the production version.


Composition Setup

Postman examples

  1. Please install Postman and import attached postman collections
    BimPlus.postman_collection.json

    postman_globals.json
    Production.postman_environment.json
    Stage.postman_environment.json

    if you don't know how it works show this video
    View file
    namePostmanCollection.mp4
    height150




  2. Set Postman authenication direct to OIDC server, avoiding authentication request on start.
    Postman supports OpenID authentication and can receive tokens directly from OIDC server.
    Open request group (or even down to single request), select Authorization page, set authorisation type 'OAuth 2.0' and configure OIDC BIm+ server.


    Image Added
    Then create Configure new token. Take server names from answer on discovery URL.
    Preferrably use variables to specify different servers for different environments. 

    Image Added
    Click "Get New Access Token". Token should be loaded in token field.
    Set "Auto-refresh Token" above to ON.
  3. Example for Ifc Import, creation of new revisions and final revision compare
    View file
    nameIfcImportWithRevisions.mp4
    height150


  4. Example for creating Modeldata 
    by using Geometry templates controller, objects controller and geometry types
     install additional postman collection 

    View file
    nameCreate Modeldata.postman_collection.json
    height150

    Some mp4, which shows usage of geometry templates, csg and mesh data
    View file
    nameCreateMeshdata.mp4
    height150

    View file
    nameCreate Geometry with BimPlus Api.mp4
    height150

    View file
    nameCreate Rooms.mp4
    height150


  5. Example for Attribute management and PSet definitions
    View file
    nameMCS Propertysets.mp4
    height150


    View file
    nameAttributes.postman_collection.json
    height250

    View file
    nameMGE_AttributeTemplateDefinitions.mp4
    height250
  6. Example for creating Alignments with REST API
    View file
    nameAlignments.mp4
    height150

    View file
    nameAlignments.postman_collection.json
    height150
  7. Example for creating StructuralAnalysis Modeldata with REST API
    you can find the same example as .NET Implementation using BIF assemblies under 
    https://github.com/Bimplus/bimplus-dotnet-demo
    View file
    nameStructuralAnalysisModel.postman_collection.json
    height150

    View file
    nameStructuralAnalysis.mp4
    height150
    View file
    nameAssembliesWithLinkToMembers.mp4
    height150
    y

C# demo projects

BimPlusCube.zip --> It explains how to create project data (nodes, geometry etc)

BimPlusDemo.zip --> It explains how to create project data (nodes, geometry etc)It explains how to authenticate, get your teams, get your project, how to create a project, how to get the project_id of your created project, create a model under the same project and upload an ifc file.


PHP Rest Client

BimplusRestClient.php (PHP REST client)

Code Block
languagephp
// Example 1: Hello function (no accessToken needed)
// ---------------------------------------------------------------------
$url = 'https://api-stage.bimplus.net/v2/hello';
$verb = 'GET';

// Create object
$request = new BimplusRestClient(
    $url,
    $verb
);

// Execute
$request->execute();
$response = $request->getResponse();

echo '<pre>';
print_r(json_decode($response));
echo '</pre>';




// Example 2: Get user data
// ---------------------------------------------------------------------
$userId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Bimplus userID
$url = 'https://api-stage.bimplus.net/v2/users/' . $userId;
$verb = 'GET';
$accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; // accessToken

// Create object
$request = new BimplusRestClient(
    $url,
    $verb,
    $accessToken
);

// Execute
$request->execute();
$response = $request->getResponse();

echo '<pre>';
print_r(json_decode($response));
echo '</pre>';



// Example 3: Update user data
// ---------------------------------------------------------------------
$userId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Bimplus userID
$url = 'https://api-stage.bimplus.net/v2/users/' . $userId;
$verb = 'PUT';
$accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; // accessToken
$requestBody = array(
    'email' => 'new.email@allplan.com'
);

// Create object
$request = new BimplusRestClient(
    $url,
    $verb,
    $accessToken,
    $requestBody
);

// Execute
$request->execute();
$response = $request->getResponse();

echo '<pre>';
print_r(json_decode($response));
echo '</pre>';


A Simple Javascript example

Code Block
languagejs
jQuery(document).ready(function() {
	jQuery("#datagrid").jqGrid({
		datatype : 'json',
		type : "GET",
		ajaxGridOptions : {
			contentType : "application/json"
		},
		loadBeforeSend : function(xhr) {
			xhr.setRequestHeader('Authorization', 'BimPlus 199c55110e2044b88e21a0c1cbb02fe3')
		},
		url : 'http://api-dev.bimplus.net/v2/teams',
		colNames : ['ID', 'Name', 'Slug', 'Status'],
		colModel : [{
			name : 'id',
			width : 200,
			align : "center",
			sortable : true
		}, {
			name : 'name',
			width : 200,
			align : "center",
			sortable : true
		}, {
			name : 'slug',
			width : 200,
			align : "center",
			sortable : true
		}, {
			name : 'status',
			width : 200,
			align : "center",
			sortable : true
		}],
		jsonReader : {
			repeatitems : false,
			root : function(obj) {
				return obj;
			},
			page : function(obj) {
				return 1;
			},
			total : function(obj) {
				return 1;
			},
			records : function(obj) {
				return obj.length;
			}
		},
		rowNum : 10,
		rowList : [10, 20, 30],
		pager : '#pager10',
		viewrecords : true,
		caption : "Bimplus Team Details",
	}).navGrid('#navGrid');
})
window.setTimeout(refreshGrid, 5000);
function refreshGrid() {
	var grid = jQuery("#datagrid");
	grid.trigger("reloadGrid");
	window.setTimeout(refreshGrid, 5000);
}


ObjectiveC (iPad) Examples

Authentication
Find out how many teams I am part of
Get team project list
Get project details
Get project topology
Get project disciplines
Upload project thumbnail
Create an issue in the project
Get the issue list from the project
Delete all the issues from the project
Create a new pin for the issue
Get all the pins of the issue
Create/Upload a new attachment for the issue
Get the attachment list from the issue

Anchor
authenticationCode
authenticationCode

Authentication

Deck of Cards
idauthenticationCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

    // building the json object
    if (([emailString length] != 0) && ([passwordString length] != 0))
    {

        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
        NSString *requestURLString = [NSString stringWithFormat:@"%@authorize",[CSS getDefaultAPIURL]];
        [request setURL:[NSURL URLWithString:requestURLString]];
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

        NSString *requestBodyString = [NSString stringWithFormat:@"{\"user_id\": \"%@\", \"password\": \"%@\", \"client_id\": \"%@\"}",emailString,passwordString,[[NSUserDefaults standardUserDefaults] objectForKey:@"ClientIdentificationForAuthorizationPurposes"]];
        [request setHTTPBody:[requestBodyString dataUsingEncoding:NSUTF8StringEncoding]];
        [request setTimeoutInterval:60];

        __block BOOL loginFailed = NO;

        __block BOOL invalidUser = NO;

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void){

            //build an info object and convert to json
            NSError *requestError;
            NSHTTPURLResponse *responseHTTP;

            NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseHTTP error:&requestError];

            if ([responseHTTP statusCode] == 200)
            {
                NSDictionary *tempdict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:&requestError];
                [CSS setUpAuthenticationForType:[tempdict valueForKey:@"token_type"] withID:[tempdict valueForKey:@"access_token"]];

                // authorization was successfull

            } else {

                loginFailed = YES;

                if (requestError.code == -1012) {

                    // Failed because it's an invalid user

                    invalidUser = YES;

                } else
Note

This web page is under construction.

...

Authentication
Find out how many teams I am part of
Get team project list
Get project details
Get project topology
Get project disciplines
Upload project thumbnail
Create an issue in the project
Get the issue list from the project
Delete all the issues from the project
Create a new pin for the issue
Get all the pins of the issue
Create/Upload a new attachment for the issue
Get the attachment list from the issue

...

Authentication

Deck of Cards
idauthenticationCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

    // building the json object
    if (([emailString length] != 0) && ([passwordString length] != 0))
    {

        NSMutableURLRequest  *request = [[NSMutableURLRequest alloc] init];
      // check NSStringif *requestURLStringproject =list [NSString stringWithFormat:@"%@authorize",[CSS getDefaultAPIURL]];
  stored on device.
      [request setURL:[NSURL URLWithString:requestURLString]];
        [request setHTTPMethod:@"POST"];
    // if yes, start [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
offline mode
        NSString *requestBodyString = [NSString stringWithFormat:@"{\"user_id\": \"%@\", \"password\": \"%@\", \"client_id\": \"%@\"}",emailString,passwordString,[[NSUserDefaults standardUserDefaults] objectForKey:@"ClientIdentificationForAuthorizationPurposes"]];

          [request setHTTPBody:[requestBodyString dataUsingEncoding:NSUTF8StringEncoding]]; }
        [request setTimeoutInterval:60]});

    }




Anchor
howManyTeamsCode
howManyTeamsCode

Find out how many teams I am part of

Deck of Cards
idhowManyTeamsCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS =  __block BOOL loginFailed = NO[CommunicationSingleton sharedSingleton];

    //build an info  __block BOOL invalidUser = NO;
object and convert to json
    NSError *requestError;
   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void){ NSHTTPURLResponse *responseHTTP;

    NSMutableURLRequest *requestForSlug = [[NSMutableURLRequest alloc] init];

   //build anNSString info*teamRequestString object= and convert to json[NSString stringWithFormat:@"%@teams",[CSS getDefaultAPIURL]];
    [requestForSlug   setURL:[NSURL URLWithString:teamRequestString]];
     NSError *requestError[requestForSlug setHTTPMethod:@"GET"];
    [requestForSlug setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [requestForSlug  NSHTTPURLResponse *responseHTTPsetValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

            NSData *responseresponseForSlug = [NSURLConnection sendSynchronousRequest:requestrequestForSlug returningResponse:&responseHTTP error:&requestError];

      [requestForSlug release];

      if ([responseHTTP statusCode] == 200) {
        // Success. Team names {array.
                NSDictionaryNSArray *tempdicttempdictForSlug = [NSJSONSerialization JSONObjectWithData:responseresponseForSlug options:NSJSONReadingMutableContainers error:&requestError];
        NSLog(@"How many teams I am part of: %d", [tempdictForSlug count]);
    }else{
        // Login Failed.
    }




Anchor
teamProjectListCode
teamProjectListCode

Get team project list

Deck of Cards
idteamProjectList


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

    //build an info object and convert to json
    NSError *requestError;
    NSHTTPURLResponse *responseHTTP; [CSS setUpAuthenticationForType:[tempdict valueForKey:@"token_type"] withID:[tempdict valueForKey:@"access_token"]];

                // authorization was successfull

            } else {

    //get projectList
    NSMutableURLRequest *requestForProjectList = [[NSMutableURLRequest    loginFailed = YESalloc] init];

                if (requestError.codeNSString *projectListRequestString == -1012) {

  [NSString stringWithFormat:@"%@%@/projects",[CSS getDefaultAPIURL],[CSS getSlug]];
    [requestForProjectList setURL:[NSURL URLWithString:projectListRequestString]];
    [requestForProjectList setHTTPMethod:@"GET"];
    [requestForProjectList setValue:@"application/json"  // Failed because it's an invalid userforHTTPHeaderField:@"Content-Type"];
    [requestForProjectList setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

    NSData *responseForProjectList = [NSURLConnection sendSynchronousRequest:requestForProjectList returningResponse:&responseHTTP error:&requestError];

    [requestForProjectList release];

    if invalidUser(responseForProjectList == NULL) YES;{

            // Login Failed
  } else {}

    else {

        NSError *error;
      // check ifNSArray project*projectList list= stored on device.
           [NSJSONSerialization JSONObjectWithData:responseForProjectList options:NSJSONReadingMutableContainers error:&error];

        BOOL //success if yes, start offline mode= [[ProjectManager sharedProjectManager] loadProjectsFromData:projectList];

        if (!success){

       }
     // Failed to Load Projects   }List

        });

    }

Card
labelC#




Anchor
howManyTeamsCodegetProjectDetailsCodehowManyTeamsCode

...

getProjectDetailsCode

Get project details

Deck of Cards
idhowManyTeamsCodegetProjectDetailsCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSONJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

    //build an info object and convert to json
    NSError *requestError;
    NSHTTPURLResponse *responseHTTP;

    NSMutableURLRequest *requestForSlug = [[NSMutableURLRequest alloc] init];

    NSString *teamRequestString = [NSString stringWithFormat:@"%@teams",[CSS getDefaultAPIURL]];
    [requestForSlug setURL:[NSURL URLWithString:teamRequestString]];
    [requestForSlug setHTTPMethod:@"GET"];
    [requestForSlug setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [requestForSlug setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]NSError *requestError;
        NSHTTPURLResponse *responseHTTP;
        NSError *dictError;

    NSData *responseForSlug = [NSURLConnection sendSynchronousRequest:requestForSlug returningResponse:&responseHTTP error:&requestError];
 //Get project details

        [requestForSlug release];

NSMutableURLRequest *requestForProjectDetails;
        requestForProjectDetails if= ([responseHTTP statusCode] == 200) {
[[NSMutableURLRequest alloc] init];

        [requestForProjectDetails setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@/projects/ Success. Team names array.
 %@",[CSS getDefaultAPIURL],[CSS getSlug],proj.mID]]];
       NSArray *tempdictForSlug = [NSJSONSerializationrequestForProjectDetails JSONObjectWithData:responseForSlug options:NSJSONReadingMutableContainers error:&requestErrorsetHTTPMethod:@"GET"];
        NSLog(@"How many teams I am part of: %d", [tempdictForSlug count]);
    }else{[requestForProjectDetails setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        [requestForProjectDetails setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

        //NSData Login Failed.
    }
Card
labelC#

...

Get team project list

Deck of Cards
idteamProjectList
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton*responseForProjectDetails = [NSURLConnection sendSynchronousRequest:requestForProjectDetails returningResponse:&responseHTTP error:&requestError];
        [requestForProjectDetails release];

    //build  an info object and convert to json
    NSError *requestError;
if (responseHTTP.statusCode == 200) {

       NSHTTPURLResponse *responseHTTP;

    //get projectList
Success, we have a NSMutableURLRequestproject *requestForProjectList = [[NSMutableURLRequest alloc] init];

detail dictionary
      NSString *projectListRequestString = [NSString stringWithFormat:@"%@%@/projects",[CSS getDefaultAPIURL],[CSS getSlug]];
 NSDictionary *projectDetails = [requestForProjectList setURL:[NSURL URLWithString:projectListRequestString]];
NSJSONSerialization JSONObjectWithData:responseForProjectDetails options:NULL error:&dictError];

    [requestForProjectList setHTTPMethod:@"GET"];
       [requestForProjectList setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [requestForProjectList setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

    NSData *responseForProjectList = [NSURLConnection sendSynchronousRequest:requestForProjectList returningResponse:&responseHTTP error:&requestError];

 // Time to process this project details as you want/need
            [requestForProjectListproj releaseprocessProjectDetails:projectDetails];

    if (responseForProjectList == NULL) }else{

            // Login Failed
    }
    else {
Download Failed
            return;
        }




Anchor
getProjectTopology
getProjectTopology

Get project topology

Deck of Cards
idgetProjectTopology


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
//build an info object and convert to json
        NSError *errorrequestError;
        NSArrayNSHTTPURLResponse *projectList = [NSJSONSerialization JSONObjectWithData:responseForProjectList options:NSJSONReadingMutableContainers error:&error]responseHTTP;

        BOOLNSString* successrequestString = [[ProjectManagerNSString sharedProjectManageralloc] loadProjectsFromData:projectList];

        if (!success){

            // Failed to Load Projects List

        }
    }
Card
labelC#

...

Get project details

Deck of Cards
idgetProjectDetailsCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

//build an info object and convert to jsoninitWithFormat:@"%@%@/projects/%@/topology",[CSS getDefaultAPIURL],[CSS getSlug], mProjectID];

        NSMutableURLRequest *requestForProjectsTree = [[NSMutableURLRequest alloc] init];
        [requestForProjectsTree setURL:[NSURL URLWithString:requestString]];
        NSError *requestError[requestString release];

        NSHTTPURLResponse *responseHTTP[requestForProjectsTree setHTTPMethod:@"GET"];
         NSError *dictError;

[requestForProjectsTree setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        [requestForProjectsTree  //Get project detailssetValue:[[CommunicationSingleton sharedSingleton] getAuthorization] forHTTPHeaderField:@"Authorization"];

        NSMutableURLRequestNSData *requestForProjectDetails;
    response = [NSURLConnection sendSynchronousRequest:requestForProjectsTree returningResponse:&responseHTTP error:&requestError];
    requestForProjectDetails  = [[NSMutableURLRequest alloc] init [requestForProjectsTree release];

        [requestForProjectDetails setURL:[NSURL URLWithStringNSString *path = [[proj getProjectFolderPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@%@/projects/%@.topology",[CSS getDefaultAPIURL],[CSS getSlug],proj.mID]]mProjectID]];

        if ([requestForProjectDetails setHTTPMethod:@"GET"];
responseHTTP statusCode] == 200)
        {
         [requestForProjectDetails setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
   // Save project topology locally.
            [requestForProjectDetailsresponse setValuewriteToFile:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"path atomically:NO];

        NSData *responseForProjectDetails = [NSURLConnection sendSynchronousRequest:requestForProjectDetails returningResponse:&responseHTTP error:&requestError];
    // Load project topology to memory.
            [requestForProjectDetailsproj releaseloadTopologyFromData:response];

        if (responseHTTP.statusCode == 200) } else {

            // Success, we have a project detail dictionary
  If Failed

          NSDictionary *projectDetails =// [NSJSONSerialization JSONObjectWithData:responseForProjectDetails options:NULL error:&dictError];

            // Time to process this project details as you want/needCheck if we have the last used topology for this project is available offline (rembember that this is could not be the last version)
            [proj processProjectDetails:projectDetails];

if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
              }else{
  // Loading project topology offline

      // Download Failed
        NSData* data =  return[NSData dataWithContentsOfFile:path];
          }
Card
labelC#

...

Get project topology

Deck of Cards
idgetProjectTopology
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

//build an info object and convert to json[proj loadTopologyFromData:data];

        NSError *requestError;
   } else {
   NSHTTPURLResponse *responseHTTP;

        NSString* requestString = [[NSString alloc] initWithFormat:@"%@%@/projects/%@/topology",[CSS getDefaultAPIURL],[CSS getSlug], mProjectID];

   / Download Failed + Local Storage not available
     NSMutableURLRequest *requestForProjectsTree = [[NSMutableURLRequest alloc] init];
  }

      [requestForProjectsTree setURL:[NSURL URLWithString:requestString]];
 }




Anchor
getProjectDisciplines
getProjectDisciplines

Get project disciplines

Deck of Cards
idgetProjectDisciplines


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
    Project* proj =  [[requestStringProjectManager releasesharedProjectManager];

        [requestForProjectsTree setHTTPMethod:@"GET" getProjectbyID:mProjectID];

    maxNodes =   [[requestForProjectsTree setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
proj getAllNodesWithoutParents] count];

    // Don't download nodes data [requestForProjectsTree setValue:[[CommunicationSingleton sharedSingleton] getAuthorization] forHTTPHeaderField:@"Authorization"];

  if we want to download them dynamically
    // we NSDataare *responsestill =going [NSURLConnection sendSynchronousRequest:requestForProjectsTree returningResponse:&responseHTTP error:&requestError];to need the parents
    if (   [requestForProjectsTree release];

    ![[[NSUserDefaults standardUserDefaults] valueForKey:kDownloadNodesDynamically] boolValue] ) {

    NSString *path = [[proj getProjectFolderPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.topology", mProjectID]]; dispatch_async(dispatch_get_main_queue(), ^(void){

        if ([responseHTTP statusCode] == 200)
mDownloadManager = [[DownloadManager   alloc] init];
   {
         mDownloadManager.delegate = self;

 // Save project topology locally.
       //get disciplines
    [response writeToFile:path atomically:NO];

       NSArray *disciplineIds = proj.projectsDisciplineIDs;
  // Load project topology to memory.
     for (int i = 0; i < [projdisciplineIds loadTopologyFromData:responsecount];

 i++) {
      } else {

        [mDownloadManager downloadFiles:[proj getAllNodesWithoutParents]  // If Failed

forProject:mProjectID forDiscipline:[disciplineIds objectAtIndex:i]];
            }

 // Check if we have the last used topology for this projectif is available offline (rembember that this is could not be the last version)
([disciplineIds count] < 1) {
                [mDownloadManager downloadFiles:[proj getAllNodesWithoutParents]  if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
forProject:mProjectID forDiscipline:NULL];
            }

        // Loading project topology offline

                NSData* data = [NSData dataWithContentsOfFile:path];
                [proj loadTopologyFromData:data];
});
    }

In "downloadFiles" method there are some logic and data storage operations and for each of the discipline you can call this snippet:


	NodeHeaderDatas *nodeDatas = [mFilesToProcess objectAtIndex:0];
	NSString *nodeidForAPICall = nodeDatas.nodeID;

	CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
	NSMutableURLRequest *requestForNodeData = [[NSMutableURLRequest alloc] init];
	NSString *nodesURL;
        if (nodeDatas.disciplineForDownloading !=  }NULL) else {
            nodesURL = [NSString  // Download Failed + Local Storage not available
stringWithFormat:
                }

        }
Card
labelC#

...

Get project disciplines

Deck of Cards
idgetProjectDisciplines
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON
@"%@%@/objects/%@/disciplines/%@/geometries/threejs",
    Project* proj = [[ProjectManager sharedProjectManager] getProjectbyID:mProjectID];

    maxNodes = [[proj getAllNodesWithoutParents] count];

    // Don't download nodes data if we want to download them dynamically
[CSS getDefaultAPIURL],
          // we are still going to need the parents
    if ( ![[[NSUserDefaultsCSS standardUserDefaults] valueForKey:kDownloadNodesDynamically] boolValue] ) {

getSlug],
                 dispatch_async(dispatch_get_main_queue(), ^(void){

      nodeidForAPICall,
      mDownloadManager = [[DownloadManager alloc] init];
            mDownloadManager.delegate = selfnodeDatas.disciplineForDownloading];

        }else{
     //get disciplines
      nodesURL = [NSString stringWithFormat:
   NSArray *disciplineIds = proj.projectsDisciplineIDs;
            for (int i = 0; i < [disciplineIds count]; i++) {
 @"%@%@/objects/%@/geometries/threejs",
                    [mDownloadManager downloadFiles:[proj getAllNodesWithoutParents] forProject:mProjectID forDiscipline:[disciplineIdsCSS objectAtIndex:i]];getDefaultAPIURL],
            }

            if ([disciplineIdsCSS countgetSlug],
  < 1) {
                [mDownloadManager downloadFiles:[proj getAllNodesWithoutParents] forProject:mProjectID forDiscipline:NULL nodeidForAPICall];

            }

        });
    }

In "downloadFiles" method there are some logic and data storage operations and for each of the discipline you can call this snippet:


	NodeHeaderDatas *nodeDatas = [mFilesToProcess objectAtIndex:0];
	NSString *nodeidForAPICall = nodeDatas.nodeID;

	CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
	NSMutableURLRequest *requestForNodeData = [[NSMutableURLRequest alloc] init];
	NSString *nodesURL;[requestForNodeData setURL:[NSURL URLWithString:nodesURL]];
        [requestForNodeData setHTTPMethod:@"GET"];
        [requestForNodeData setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        [requestForNodeData setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

        if (nodeDatas.disciplineForDownloading != NULL) (requestForNodeData){
            nodesURLmConnection = [[NSString stringWithFormat:
  NSURLConnection alloc] initWithRequest:requestForNodeData delegate:self startImmediately:YES];
        }
if (!mConnection)
        {
     @"%@%@/objects/%@/disciplines/%@/geometries/threejs",
       // Connection Failed
        }
       [CSS getDefaultAPIURL],else
        {
            [mConnection scheduleInRunLoop:[NSRunLoop   [CSS getSlug],currentRunLoop] forMode:NSRunLoopCommonModes];
            [mConnection start];
        }
   nodeidForAPICall,
     [requestForNodeData release];




Anchor
uploadThumbnailCode
uploadThumbnailCode

Upload project thumbnail

Deck of Cards
iduploadThumbnailCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
NSString *urlString = [[CSS getDefaultAPIURL] stringByAppendingFormat:@"%@/projects/%@/thumbnail",[CSS getSlug],currentProject.mID];
MultIPartFormCommunication *MPC = [MultIPartFormCommunication sharedSingleton];
if (![MPC uploadImage:imagePlaceholder.image withExtension:@"jpeg" withFileName:@"thumbnail" ToURLString:urlString]){
[[ProjectManager sharedProjectManager] addUnUploadedThumbnailsProjectIdToList:currentProject.mID];
}

See the bottom of the page to see the uploadImage method



Anchor
createIssueProjectCode
createIssueProjectCode

Create an issue in the project

Deck of Cards
idcreateIssueProjectCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
//get its dictionary:
    NSMutableDictionary *currentIssueData = [self getIssueInformationForIssueId:ISSUE_ID];

    //create nsdata for uploading:
    NSError *error;
    NSData *dataForCurrentIssue = [NSJSONSerialization dataWithJSONObject:currentIssueData options:NSJSONWritingPrettyPrinted error:&error];

    //create issue request:
    NSMutableURLRequest *uploadRequestForCurrentIssue;
    uploadRequestForCurrentIssue = [[NSMutableURLRequest alloc] init         nodeDatas.disciplineForDownloading];
        }else{
            nodesURL = [NSString stringWithFormat:
                        @"%@%@/objects/%@/geometries/threejs",
                        [CSS getDefaultAPIURL],
                        [CSS getSlug],
                        nodeidForAPICall];

    NSString *urlStringForIssue =  }
   [NSString stringWithFormat:@"%@%@/projects/%@/issues",
     [requestForNodeData setURL:[NSURL URLWithString:nodesURL]];
        [requestForNodeData setHTTPMethod:@"GET"];
        [requestForNodeData setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        [requestForNodeData setValue:[CSS getAuthorizationgetDefaultAPIURL] forHTTPHeaderField:@"Authorization"];

,
         if(requestForNodeData){
            mConnection = [[NSURLConnection alloc] initWithRequest:requestForNodeData delegate:self startImmediately:YES];
        }
if (!mConnection)[CSS getSlug],
        {
            // Connection Failed
        }
     self.mID];

   else
 [uploadRequestForCurrentIssue setURL:[NSURL URLWithString:urlStringForIssue]];
     {[uploadRequestForCurrentIssue setHTTPMethod:@"POST"];
    [uploadRequestForCurrentIssue setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
      [mConnectionuploadRequestForCurrentIssue scheduleInRunLoopsetValue:[NSRunLoopCSS currentRunLoopgetAuthorization] forMode:NSRunLoopCommonModesforHTTPHeaderField:@"Authorization"];
    [uploadRequestForCurrentIssue setHTTPBody:dataForCurrentIssue];

       [mConnection start];NSHTTPURLResponse *responseHTTPForCurrentIssue;

    NSData *responseForCurrentIssue =  }
   [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentIssue returningResponse:&responseHTTPForCurrentIssue error:&error];
     [requestForNodeDatauploadRequestForCurrentIssue release];

Card
labelC#

...

Upload project thumbnail

...

iduploadThumbnailCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
NSString *urlString = [[CSS getDefaultAPIURL] stringByAppendingFormat:@"%@/projects/%@/thumbnail",[CSS getSlug],currentProject.mID];
MultIPartFormCommunication *MPC = [MultIPartFormCommunication sharedSingleton];
if (![MPC uploadImage:imagePlaceholder.image withExtension:@"jpeg" withFileName:@"thumbnail" ToURLString:urlString]){
[[ProjectManager sharedProjectManager] addUnUploadedThumbnailsProjectIdToList:currentProject.mID];
}
    if ([responseHTTPForCurrentIssue statusCode] == 201) {
        // Success, issue uploaded
    }else{
        // Error, upload failed
    }




Anchor
getIssueListCode
getIssueListCode

Get the issue list from

...

labelC#

...

the project

Deck of Cards
idcreateIssueProjectCodegetIssueListCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    //create issue request:
    NSMutableURLRequest *issueListRequest;
    issueListRequest = [[NSMutableURLRequest alloc] init];

    NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/projects/%@/issues",
                                   [CSS getDefaultAPIURL],
                                   [CSS getSlug],
                                   self.mID];
    DLog(@"%@",urlStringForIssue);
    [issueListRequest setURL:[NSURL URLWithString:urlStringForIssue]];
    [issueListRequest setHTTPMethod:@"GET"];
    [issueListRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [issueListRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

    NSHTTPURLResponse *responseHTTPForIssueList;
    NSError *error;

    NSData *rawIssueList = [NSURLConnection sendSynchronousRequest:issueListRequest returningResponse:&responseHTTPForIssueList error:&error];
    [issueListRequest release];

    if ([responseHTTPForIssueList statusCode] == 200) {

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
//get its dictionary:
    NSMutableDictionary *currentIssueData = [self getIssueInformationForIssueId:ISSUE_ID];

    //create nsdata for uploading:
    NSError *error;
    NSData *dataForCurrentIssue = [NSJSONSerialization dataWithJSONObject:currentIssueData options:NSJSONWritingPrettyPrinted error:&error];

    //create issue request:
    NSMutableURLRequest *uploadRequestForCurrentIssue;
    uploadRequestForCurrentIssue = [[NSMutableURLRequest alloc] init];

    NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/projects/%@/issues",
                                   [CSS getDefaultAPIURL],
                 NSMutableArray *issueList                 [CSS getSlug],= [NSJSONSerialization JSONObjectWithData:rawIssueList options:NSJSONReadingMutableContainers error:&error];
        return  issueList;
    }else{
        return NULL;
    }




Anchor
deleteIssueListCode
deleteIssueListCode

Delete all the issues from the project

Deck of Cards
iddeleteIssueListCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
//delete it form the server
	CommunicationSingleton *CSS = [CommunicationSingleton self.mIDsharedSingleton];

    [uploadRequestForCurrentIssue setURL:[NSURL URLWithString:urlStringForIssue]];
    [uploadRequestForCurrentIssue setHTTPMethod:@"POST"];
	//create issue request:
	NSMutableURLRequest *deleteRequest = [[NSMutableURLRequest alloc] init];

	NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@",
    [uploadRequestForCurrentIssue setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [uploadRequestForCurrentIssue setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
    [uploadRequestForCurrentIssue setHTTPBody:dataForCurrentIssue];

    NSHTTPURLResponse *responseHTTPForCurrentIssue;

    NSData *responseForCurrentIssue = [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentIssue returningResponse:&responseHTTPForCurrentIssue error:&error];
    [uploadRequestForCurrentIssue release];

    if ([responseHTTPForCurrentIssueCSS statusCodegetDefaultAPIURL] == 201) {
,
              // Success, issue uploaded
    }else{
        // Error, upload failed
    }
Card
labelC#

...

       [CSS getSlug],
                                           issueid];

	[deleteRequest setURL:[NSURL URLWithString:urlStringForIssue]];
	[deleteRequest setHTTPMethod:@"DELETE"];
	[deleteRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
	[deleteRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

	NSHTTPURLResponse *responseHTTPForDeletion;
	[NSURLConnection sendSynchronousRequest:deleteRequest returningResponse:&responseHTTPForDeletion error:&error];
	[deleteRequest release];

	if ([responseHTTPForDeletion statusCode] == 200) {

		//successful deletion
		return 0;

	} else {

	//add it to a deletion list
	[self addIssueToUnDeletedIssueList:issueid];

	return 1;

	}




Anchor
createNewPinCode
createNewPinCode

Create a new pin for the issue

Deck of Cards
idcreateNewPinCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

	NSMutableDictionary *pinData = [self getPinDataForPinId:PIN_ID inIssue:ISSUE_ID];

	//remove the id and the objectsparent id since they are unrequired data for the server:
	NSString *oldObjectsParentID = [pinData objectForKey:@"objectsParentId"];
	[pinData removeObjectForKey:@"objectsParentId"];
	NSString *oldPinId = [pinData objectForKey:@"id"];
	[pinData removeObjectForKey:@"id"];

	//set the new issue id:
	[pinData setObject:newCurrentIssueId forKey:@"issueId"];

	//create nsdata for uploading:
	NSData *dataForCurrentPin = [NSJSONSerialization dataWithJSONObject:pinData options:NSJSONWritingPrettyPrinted error:&error];

	//create pin request:
	NSMutableURLRequest *uploadRequestForCurrentPin;
	uploadRequestForCurrentPin = [[NSMutableURLRequest alloc] init];

	NSString *urlStringForPin = [NSString stringWithFormat:@"%@%@/issues/%@/pins",

...

Get the issue list from the project

Deck of Cards
idgetIssueListCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    //create issue request:
    NSMutableURLRequest *issueListRequest;
    issueListRequest = [[NSMutableURLRequest alloc] init];

    NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/projects/%@/issues",
                                   [CSS getDefaultAPIURL],
                                   [CSS getSlug],
                                   self.mID];
    DLog(@"%@",urlStringForIssue);
    [issueListRequest setURL:[NSURL URLWithString:urlStringForIssue]];
    [issueListRequest setHTTPMethod:@"GET"];
    [issueListRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [issueListRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

 getDefaultAPIURL],
      NSHTTPURLResponse *responseHTTPForIssueList;
    NSError *error;

    NSData *rawIssueList = [NSURLConnection sendSynchronousRequest:issueListRequest returningResponse:&responseHTTPForIssueList error:&error];
    [issueListRequest release];

    if ([responseHTTPForIssueList statusCode] == 200) {[CSS getSlug],
        NSMutableArray  *issueList = [NSJSONSerialization JSONObjectWithData:rawIssueList options:NSJSONReadingMutableContainers error:&error];
        return  issueList;
    }else{
      self.newCurrentIssueID];

	[uploadRequestForCurrentPin  return NULL;
    }
Card
labelC#

...

setURL:[NSURL URLWithString:urlStringForPin]];
	[uploadRequestForCurrentPin setHTTPMethod:@"POST"];
	[uploadRequestForCurrentPin setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
	[uploadRequestForCurrentPin setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
	[uploadRequestForCurrentPin setHTTPBody:dataForCurrentPin];
NSHTTPURLResponse *responseHTTPForCurrentPin;

	NSData *responseForCurrentPin = [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentPin returningResponse:&responseHTTPForCurrentPin error:&error];
	[uploadRequestForCurrentPin release];

	if ([responseHTTPForCurrentPin statusCode] == 201) {
		// success
	} else {
		// Upload Failed
	}




Anchor
getPinListCode
getPinListCode

Get all the pins of the issue

Deck of Cards
idgetPinListCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    //create issue request:
    NSMutableURLRequest *pinListRequest;
    pinListRequest = [[NSMutableURLRequest alloc] init];

    NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@/pins",

...

Delete all the issues from the project

Deck of Cards
iddeleteIssueListCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

//delete it form the server
	CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
	//create issue request:
	NSMutableURLRequest *deleteRequest = [[NSMutableURLRequest alloc] init];

	NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@",
                                           [CSS getDefaultAPIURL],
                                           [CSS getSlug],
                                           issueid];

	[deleteRequest setURL:[NSURL URLWithString:urlStringForIssue]];
	[deleteRequest setHTTPMethod:@"DELETE"];
	[deleteRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
	[deleteRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

	NSHTTPURLResponse *responseHTTPForDeletion;
	[NSURLConnection sendSynchronousRequest:deleteRequest returningResponse:&responseHTTPForDeletion error:&error];
	[deleteRequest release];

	if ([responseHTTPForDeletion statusCode] == 200) {

		//successful deletion
		return 0;

	} else {

	//add it to a deletion list
	[self addIssueToUnDeletedIssueList:issueid];

	return 1;

	}
Card
labelC#

...

Create a new pin for the issue

Deck of Cards
idcreateNewPinCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];

	NSMutableDictionary *pinData = [self getPinDataForPinId:PIN_ID inIssue:ISSUE_ID];

	//remove the id and the objectsparent id since they are unrequired data for the server:
	NSString *oldObjectsParentID = [pinData objectForKey:@"objectsParentId"];
	[pinData removeObjectForKey:@"objectsParentId"];
	NSString *oldPinId = [pinData objectForKey:@"id"];
	[pinData removeObjectForKey:@"id"];

	//set the new issue id:
	[pinData setObject:newCurrentIssueId forKey:@"issueId"];

	//create nsdata for uploading:
	NSData *dataForCurrentPin = [NSJSONSerialization dataWithJSONObject:pinData options:NSJSONWritingPrettyPrinted error:&error];

	//create pin request:
	NSMutableURLRequest *uploadRequestForCurrentPin;
	uploadRequestForCurrentPin = [[NSMutableURLRequest alloc] init];

	NSString *urlStringForPin = [NSString stringWithFormat:@"%@%@/issues/%@/pins",
                   [CSS getDefaultAPIURL],
                                   [CSS getSlug],
                                   issueid];
    DLog(@"%@",urlStringForIssue);
    [pinListRequest setURL:[NSURL URLWithString:urlStringForIssue]];
    [pinListRequest setHTTPMethod:@"GET"];
    [pinListRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [pinListRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];

    NSHTTPURLResponse *responseHTTPForPinList;
    NSError *error;

    NSData *rawPinList = [NSURLConnection sendSynchronousRequest:pinListRequest returningResponse:&responseHTTPForPinList error:&error];
    [pinListRequest release];

    if ([responseHTTPForPinList statusCode] == 200) {
        NSMutableArray *pinList = [NSJSONSerialization JSONObjectWithData:rawPinList    options:NSJSONReadingMutableContainers error:&error];
   [CSS getDefaultAPIURL],
    return  pinList;
    }else{
        return NULL;
    }




Anchor
createAttachmentForIssueCode
createAttachmentForIssueCode

Create/Upload a new attachment for the issue

Deck of Cards
idcreateAttachmentForIssueCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON
NSString *attachmentURL = [[CSS getDefaultAPIURL] stringByAppendingFormat:@"%@/issues/%@/attachments", [CSS      [CSS getSlug],
           getSlug],currentIssueId];
	MultIPartFormCommunication *MPC = [MultIPartFormCommunication sharedSingleton];
	NSString *imageName = [NSString stringWithFormat:@"issueImage%f",[[NSDate date] timeIntervalSince1970]];
	if ([MPC uploadImage:issueImage withExtension:@"jpeg" withFileName:imageName ToURLString:attachmentURL]){
                //succesful uploading
       self.newCurrentIssueID];

	[uploadRequestForCurrentPin setURL:[NSURL URLWithString:urlStringForPin]];
	[uploadRequestForCurrentPin setHTTPMethod:@"POST"];
	[uploadRequestForCurrentPin setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
	[uploadRequestForCurrentPin setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
	[uploadRequestForCurrentPin setHTTPBody:dataForCurrentPin];
NSHTTPURLResponse *responseHTTPForCurrentPin;

	NSData *responseForCurrentPin = [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentPin returningResponse:&responseHTTPForCurrentPin error:&error];
	[uploadRequestForCurrentPin release];

	if ([responseHTTPForCurrentPin statusCode] == 201) {
		// success
	} else {
		// Upload Failed
	}

Card
labelC#

...

 }else{
                //unsuccesful uploading store the issue image in a list:
            }

See the bottom of the page to see the uploadImage method



Anchor
getAttachmentListFromIssueCode
getAttachmentListFromIssueCode

Get the attachment list from the issue

Deck of Cards
idgetPinListCodegetAttachmentListFromIssueCode


C#
Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    //create issue request:
    NSMutableURLRequest *pinListRequestattachmentsRequest;
    pinListRequestattachmentsRequest = [[NSMutableURLRequest alloc] init];
    
    NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@/pinsattachments",
                                   [CSS getDefaultAPIURL],
                                   [CSS getSlug],
                                   issueid];
    DLog(@"%@",urlStringForIssue);
    [pinListRequestattachmentsRequest setURL:[NSURL URLWithString:urlStringForIssue]];
    [pinListRequestattachmentsRequest setHTTPMethod:@"GET"];
    [pinListRequestattachmentsRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [pinListRequestattachmentsRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
    
    NSHTTPURLResponse *responseHTTPForPinListresponseHTTPForAttachments;
    NSError *error;
    
    NSData *rawPinListrawAttachmentsList = [NSURLConnection sendSynchronousRequest:pinListRequestattachmentsRequest returningResponse:&responseHTTPForPinListresponseHTTPForAttachments error:&error];
    [pinListRequestattachmentsRequest release];
    
    if ([responseHTTPForPinListresponseHTTPForAttachments statusCode] == 200) {
        NSMutableArray *pinListattachmentsList = [NSJSONSerialization JSONObjectWithData:rawPinListrawAttachmentsList options:NSJSONReadingMutableContainers error:&error];
        if ([attachmentsList count] > 0) {
            return  pinList;
 attachmentsList;
        }else{
            return NULL;
        }
    }else{
        return NULL;
    }
Card
label




Anchor
createAttachmentForIssueCodeuploadImageCodecreateAttachmentForIssueCode
uploadImageCode

...

Upload image utility method for ObjectiveC

Deck of Cards
idcreateAttachmentForIssueCodeuploadImageCode


Card
labelObjectiveC


Code Block
borderColorGreen
langjava
titleJSON

NSString *attachmentURL = [[CSS getDefaultAPIURL] stringByAppendingFormat:@"%@/issues/%@/attachments", [CSS getSlug],currentIssueId];
	MultIPartFormCommunication *MPC = [MultIPartFormCommunication sharedSingleton];
	NSString *imageName = [NSString stringWithFormat:@"issueImage%f",[[NSDate date] timeIntervalSince1970]];
	if ([MPC uploadImage:issueImage withExtension:@"jpeg" withFileName:imageName ToURLString:attachmentURL]){- (BOOL)uploadImage:(UIImage*)image withExtension:(NSString*)ext withFileName:(NSString*)fileName ToURLString:(NSString*)urlString{

    CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    NSURL *url =  //succesful uploading[NSURL URLWithString:urlString];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    // }else{Method
    [request setHTTPMethod:@"POST"];

    // Set headers
     //unsuccesful uploading store the issue image in a list:
     NSString *boundary = @"AaB03x";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];

    [request setValue:[CSS  }

Card
labelC#

...

Get the attachment list from the issue

Deck of Cards
idgetAttachmentListFromIssueCode
C#
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON

CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    NSMutableURLRequest *attachmentsRequest;
    attachmentsRequest = [[NSMutableURLRequest alloc] initgetAuthorization] forHTTPHeaderField:@"Authorization"];
    [request addValue:contentType forHTTPHeaderField:@"Content-Type"];

    // FORM
    NSData *dataForTestImage = UIImageJPEGRepresentation(image, 1.0);
    NSMutableData *body = [NSMutableData data];

    [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSString *urlStringForIssue = [body appendData:[[NSString stringWithFormat:@"%@%@/issues/%@/attachments",
  "Content-Disposition: form-data; name=\"file\"; filename=\"%@.%@\"\r\n", fileName,ext] dataUsingEncoding:NSUTF8StringEncoding]];
    [body         appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:dataForTestImage];

    // fileName
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",    [CSS getDefaultAPIURL],boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"fileName\"\r\n\r\n%@.%@", fileName,ext] dataUsingEncoding:NSUTF8StringEncoding]];

    // type
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"type\"\r\n\r\nimage/%@",    [CSS getSlug],ext] dataUsingEncoding:NSUTF8StringEncoding]];

    // size
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"size\"\r\n\r\n%d", [dataForTestImage length]] dataUsingEncoding:NSUTF8StringEncoding]];


         // objectIds
  issueid];
  [body  DLog(@"%@",urlStringForIssue)appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [attachmentsRequestbody setURLappendData:[NSURL URLWithString:urlStringForIssue[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"objectIds\"\r\n\r\n%@", @""]
dataUsingEncoding:NSUTF8StringEncoding]];

    [attachmentsRequest setHTTPMethod:@"GET"];// End
    [attachmentsRequestbody setValue:@"application/json" forHTTPHeaderFieldappendData:[[NSString stringWithFormat:@"Content-Type"];\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    [attachmentsRequestrequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
    setHTTPBody:body];

    NSHTTPURLResponse* *responseHTTPForAttachmentsresponse;
    NSError *error;
    
    NSData *rawAttachmentsList = [NSURLConnection sendSynchronousRequest:attachmentsRequest returningResponse:&responseHTTPForAttachments error:&error] err;
    [attachmentsRequest release];NSURLConnection sendSynchronousRequest:request
    
    if ([responseHTTPForAttachments statusCode] == 200) {
        NSMutableArray *attachmentsList = [NSJSONSerialization JSONObjectWithData:rawAttachmentsList options:NSJSONReadingMutableContainers errorreturningResponse:&error];response
        if ([attachmentsList count] > 0) {
            return attachmentsList;
        }else{
    error:&err];

    if ([response statusCode] == return201) NULL;{
        return }true;
    }else{
        return NULLfalse;
    }
}

Card
label