Community
BIM 360 API Forum
Welcome to Autodesk’s BIM 360 API Forums. Share your knowledge, ask questions, and explore popular BIM 360 API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bim 360 FIELD Publish - InternalServerError when user isn't Document Manager

6 REPLIES 6
Reply
Message 1 of 7
clwi
528 Views, 6 Replies

Bim 360 FIELD Publish - InternalServerError when user isn't Document Manager

clwi
Enthusiast
Enthusiast

Hi,

 

We've noticed today that we get InternalServerError when we're trying to Publish a file and lacks the proper accesslevel in the project.(Not set as Document Manager).

public static HttpStatusCode Publish(string ticket, string project_id, string directory, string filename, byte[] bytes, string document_id, string tags, string caption)
{
// (1) Build request
var client = new RestClient();
client.BaseUrl = new System.Uri(Settings.baseUrl);

// Set resource or end point
var request = new RestRequest();
request.Resource = "/api/library/publish";
request.Method = Method.POST;

// Add parameters
request.AddParameter("ticket", ticket);
request.AddParameter("project_id", project_id);

request.AddParameter("directory", directory);
request.AddParameter("filename", filename);

// Optional parameters
if (!string.IsNullOrEmpty(document_id))
request.AddParameter("document_id", document_id);
request.AddParameter("tags", tags);
if (!string.IsNullOrEmpty(caption))
request.AddParameter("caption", caption);

// Add Files
request.AddFile("Filedata", bytes, filename);

// (2) Execute request and get response
IRestResponse response = client.Execute(request);

// Save response. This is to see the response for our learning.
Settings.m_lastResponse = response;

return response.StatusCode;

}

What would be the proper way to ensure/check the access either before upload or maybe get a proper response like "Unable to publish file. Insufficient user rights" or something so I can actually handle it?

 

 

 

0 Likes

Bim 360 FIELD Publish - InternalServerError when user isn't Document Manager

Hi,

 

We've noticed today that we get InternalServerError when we're trying to Publish a file and lacks the proper accesslevel in the project.(Not set as Document Manager).

public static HttpStatusCode Publish(string ticket, string project_id, string directory, string filename, byte[] bytes, string document_id, string tags, string caption)
{
// (1) Build request
var client = new RestClient();
client.BaseUrl = new System.Uri(Settings.baseUrl);

// Set resource or end point
var request = new RestRequest();
request.Resource = "/api/library/publish";
request.Method = Method.POST;

// Add parameters
request.AddParameter("ticket", ticket);
request.AddParameter("project_id", project_id);

request.AddParameter("directory", directory);
request.AddParameter("filename", filename);

// Optional parameters
if (!string.IsNullOrEmpty(document_id))
request.AddParameter("document_id", document_id);
request.AddParameter("tags", tags);
if (!string.IsNullOrEmpty(caption))
request.AddParameter("caption", caption);

// Add Files
request.AddFile("Filedata", bytes, filename);

// (2) Execute request and get response
IRestResponse response = client.Execute(request);

// Save response. This is to see the response for our learning.
Settings.m_lastResponse = response;

return response.StatusCode;

}

What would be the proper way to ensure/check the access either before upload or maybe get a proper response like "Unable to publish file. Insufficient user rights" or something so I can actually handle it?

 

 

 

Tags (1)
6 REPLIES 6
Message 2 of 7
mikako_harada
in reply to: clwi

mikako_harada
Community Manager
Community Manager

Hi clwi, 

 

It would be nicer to have an error message saying the nature of failure than internal error, wouldn't it? 

 

I see two calls, fieldapi/admin/v1/users and api/v1/projects/{project_id}/users return a list of users with roles: 

 

https://bim360field.autodesk.com/apidoc/index.html#admin_api_method_6

https://bim360field.autodesk.com/apidoc/index.html#api/v1/project_users_method_1

 

Maybe what you can do will be to check the individual's role there after the user login and use that info.  

 


Mikako Harada
Developer Technical Services
0 Likes

Hi clwi, 

 

It would be nicer to have an error message saying the nature of failure than internal error, wouldn't it? 

 

I see two calls, fieldapi/admin/v1/users and api/v1/projects/{project_id}/users return a list of users with roles: 

 

https://bim360field.autodesk.com/apidoc/index.html#admin_api_method_6

https://bim360field.autodesk.com/apidoc/index.html#api/v1/project_users_method_1

 

Maybe what you can do will be to check the individual's role there after the user login and use that info.  

 


Mikako Harada
Developer Technical Services
Message 3 of 7
clwi
in reply to: mikako_harada

clwi
Enthusiast
Enthusiast
i tried using the get users function(second suggestion) copying my publish function and modifying it to match the information but i kept getting unauthorized when trying that, maybe i missed something, you think you can try rewrite my function to match the api, maybe i understand where i went wrong there...


but yea, also, wtb a proper error message 🙂
0 Likes

i tried using the get users function(second suggestion) copying my publish function and modifying it to match the information but i kept getting unauthorized when trying that, maybe i missed something, you think you can try rewrite my function to match the api, maybe i understand where i went wrong there...


but yea, also, wtb a proper error message 🙂
Message 4 of 7
mikakoharada
in reply to: clwi

mikakoharada
Observer
Observer

(sorry please ignore this one)

0 Likes

(sorry please ignore this one)

Message 5 of 7
mikako_harada
in reply to: clwi

mikako_harada
Community Manager
Community Manager

Hi clwi,

 

if you are getting unauthorized, maybe you don't have an access right for the user data. That will be a limitation.  

 

Also, just in case, if you are having a problem just to call /users, could you make sure you are passing project_id as a URL parameter, not a form parameter? e.g., using RESTShape, it will look like this: 

 

>>>>

request.Resource = "/api/v1/projects/{project_id}/users

 

request.AddUrlSegment("project_id", project_id);

<<<<


Mikako Harada
Developer Technical Services
0 Likes

Hi clwi,

 

if you are getting unauthorized, maybe you don't have an access right for the user data. That will be a limitation.  

 

Also, just in case, if you are having a problem just to call /users, could you make sure you are passing project_id as a URL parameter, not a form parameter? e.g., using RESTShape, it will look like this: 

 

>>>>

request.Resource = "/api/v1/projects/{project_id}/users

 

request.AddUrlSegment("project_id", project_id);

<<<<


Mikako Harada
Developer Technical Services
Message 6 of 7
clwi
in reply to: mikako_harada

clwi
Enthusiast
Enthusiast

Hi,

 

still cannot get it to work.. i'm currently getting NotFound results now...

 

my current meethod...

 

public static HttpStatusCode IsDoucmentManager(string ticket, string project_id, string user_id )
{
// (1) Build request
var client = new RestClient();
client.BaseUrl = new System.Uri("https://bim360field.eu.autodesk.com");
// Set resource or end point
var request = new RestRequest();
request.Resource = "/api/v1/projects/{project_id}/users";
request.AddUrlSegment("project_id", project_id);
request.Method = Method.GET;

// Add parameters
request.AddParameter("ticket", ticket);

//request.AddParameter("project_id", project_id);
//request.AddParameter("id", user_id);
// (2) Execute request and get response
IRestResponse response = client.Execute(request);

Settings.m_lastResponse = response;

return response.StatusCode;

}

 

Any advice?

0 Likes

Hi,

 

still cannot get it to work.. i'm currently getting NotFound results now...

 

my current meethod...

 

public static HttpStatusCode IsDoucmentManager(string ticket, string project_id, string user_id )
{
// (1) Build request
var client = new RestClient();
client.BaseUrl = new System.Uri("https://bim360field.eu.autodesk.com");
// Set resource or end point
var request = new RestRequest();
request.Resource = "/api/v1/projects/{project_id}/users";
request.AddUrlSegment("project_id", project_id);
request.Method = Method.GET;

// Add parameters
request.AddParameter("ticket", ticket);

//request.AddParameter("project_id", project_id);
//request.AddParameter("id", user_id);
// (2) Execute request and get response
IRestResponse response = client.Execute(request);

Settings.m_lastResponse = response;

return response.StatusCode;

}

 

Any advice?

Message 7 of 7
mikako_harada
in reply to: clwi

mikako_harada
Community Manager
Community Manager

Hi clwi, 

 

The code looks correct to me.

 

A few places I can think of as places to check - 

 

Does the current API user has an access to the project pointed by project_id?

 

You may try as a full access user and see if it works.  This may help to separate if the issue is permission/projects with the current user or some where in the logic of the code, for example.  

 


Mikako Harada
Developer Technical Services
0 Likes

Hi clwi, 

 

The code looks correct to me.

 

A few places I can think of as places to check - 

 

Does the current API user has an access to the project pointed by project_id?

 

You may try as a full access user and see if it works.  This may help to separate if the issue is permission/projects with the current user or some where in the logic of the code, for example.  

 


Mikako Harada
Developer Technical Services

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report