Jump to content

Rest API Add and Checkin POST methods fail with error 500


FuzzkingCool

Recommended Posts

Hi,

I'm having some issues with the restful api add method. It always returns the status code 500.

Here is some sample code ( in python ) to add a file as a pending change to a workspace:
 

API_URL = 'http://localhost:9090/api/v1'

workspace = "testWorkspace"

path = "Assets/Shaders/NewSurfaceShader.shader"

url = '%s/wkspaces/%s/content/%s' % ( API_URL , workspace , path )

paramsDict = {  'addPrivateParents' : True  ,  'checkoutParent' : True , 'recurse' : False }

params = str( json.dumps( inParamsDict ) )

response = requests.post( url = url.strip() , data = params )


The url that is formed looks like this: 

http://localhost:9090/api/v1/wkspaces/testWorkspace/content/Assets/Shaders/NewSurfaceShader.shader

The params dict is formatted as json like so:

{"recurse": false, "checkoutParent": true, "addPrivateParents": true}

I tried without passing the parameters, I have tried with just a directory instead of a file.
I have also tried a PUT method, which does not fail, but the response of "affectedPaths" is an empty list.

What could be going wrong here?

Link to comment
Share on other sites

Hi karmakat,

Could you share the response body you're getting with those errors? That could give us more information on what's going on.

 

Additionally, could you configure the plasticAPI logging? You'd just need to create a file called 'plasticapi.log.conf' in the client binaries directory with this content:

<log4net>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="plasticapi.client.log" /> <!-- change this value to any path you want -->
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="5" />
    <maximumFileSize value="10MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %username %-5level %logger - %message%newline" />
    </layout>
  </appender>

  <root>
    <level value="DEBUG" />
    <appender-ref ref="RollingFileAppender" />
  </root>
</log4net>

That will create a file called plasticapi.client.log in the client binaries directory, so make sure you have permissions to write in that path or change it in the marked <file> tag. Please run the requests again and share the output and the generated log file with us.

Thank you!

 

Regards,

Miguel

Link to comment
Share on other sites

Hi Miguel,

Ok, I have done as you requested. 

Here is the log:

Quote

2017-07-11 09:10:42,128 SL02\admin DEBUG ClientConfig - Time loading client.conf (C:\Users\admin\AppData\Local\plastic4\client.conf) 31 ms
2017-07-11 09:10:42,160 SL02\admin INFO  APIListener - Starting API endpoint on http://localhost:9090
2017-07-11 09:10:42,238 SL02\admin ERROR App - Exception has been thrown by the target of an invocation.

The response from the server: 
 

Quote

<Response [500]>

and as json:

Quote

{u'code': 500, u'message': u"Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details."}

This message is a little misleading since no exception is raised, and the response object from requests module does not contain a property 'Response'.

However, when I printed out the __dict__ property of the the response object, I received this:

Quote

{'cookies': <RequestsCookieJar[]>, '_content': '{"message":"Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the \'Response\' property of this exception for details.","code":500}', 'headers': {'Date': 'Tue, 11 Jul 2017 13:15:19 GMT', 'Content-Length': '177', 'Content-Type': 'application/json; charset=utf-8', 'Server': 'Microsoft-HTTPAPI/2.0'}, 'url': u'http://localhost:9090/api/v1/wkspaces/testWorkspace/content/Assets/Shaders/NewSurfaceShader.shader', 'status_code': 500, '_content_consumed': True, 'encoding': 'utf-8', 'request': <PreparedRequest >, 'connection': <requests.adapters.HTTPAdapter object at 0x0000000004394978>, 'elapsed': datetime.timedelta(0, 0, 1565), 'raw': <requests.packages.urllib3.response.HTTPResponse object at 0x00000000043C12B0>, 'reason': 'Internal Server Error', 'history': []}

I should mention that I have only done a very superficial configuration of my server as in the docs, which I am testing on my local machine as I develop code and wait for our server hardware to come in.

I should also mention that the cm cli works fine for these operations.

Thanks for your help!

 

Link to comment
Share on other sites

Hi karmakat,

How is your Plastic SCM client configured? Are you using the SSL protocol? If that's the case, are you using a valid certificate? Could you attach the output of a 'cm lrep' command?

Could you also describe to us your current workspace structure so that we can try to reproduce your issue? 

Thank you!

 

Regards,

Miguel

Link to comment
Share on other sites

  • 2 weeks later...

Hi, 

I ended up using the cm client instead because I had to move on with pipeline development.

I am currently testing my server and client locally during development, so I am not using SSL yet.

Running 'cm lrep'  results in:

    default@localhost:8087
    repo_zero@localhost:8087

 

Workspace structure doesn't matter... it does not work with any arbitrary structure. I have tried from scratch many times with only the most basic directory structure within the workspace.



 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...