You are viewing limited content. For full access, please sign in.

Question

Question

Calling Laserfiche API Through Web Request Rule - Search Task 404 Not Found

asked on June 19 Show version history

I am trying to start a search task and then retrieve the results using the Laserfiche API.

This is my POST request which starts the asynchronous search task:

 

And this succeeds and returns a taskId:

202
...
{
  "@odata.context": "https://api.laserfiche.ca/repository/v2/$metadata#Laserfiche.Repository.StartTaskResponse",
  "taskId": "82a5dbf1-073d-4fd8-8c6a-61a9fe513832"
}

 

EDIT: It returns a 202 response but it also returns a location URL (ex: https://api.laserfiche.ca/repository/v2/Repositories/r-0001/Tasks?taskIds=9e18b8b2-5486-41dc-99e7-69bf34f524f6) and in this URL it actually says:

 

{"type":"accessDenied","title":"Error: Invalid or expired access token.","status":401,"instance":"/repository/v2/Repositories/r-0001/Tasks","operationId":"478c3c68079b435fa28749a2e344df72","errorSource":"Api Server","errorCode":201,"traceId":"00-e4013d8c132147dd521435a9cb3d43e4-66466f83a9298503-00"}

So it's actually failing but in the Web Request response page it shows 202.

 

 

When I then try to get the results for the task with id taskId though using a GET request:

404
...
{
  "type": "https://httpstatuses.io/404",
  "title": "Not Found",
  "status": 404,
  "traceId": "00-d86d6c7d786223c1b70ebc82f4fdcbb0-f04ed7295c1f8965-00"
}

A 404 response means "Request taskId not found." and I am not sure why there is no trace of it. I tried to wait for a minute before running the GET task and it still gets the 404 error. I also tried running it directly in a workflow and the taskId is never found. Any ideas of why this could be?

0 0

Answer

SELECTED ANSWER
replied on June 20

Your URI looks incorrect in the screenshot for the GET request. You have "/v2/Repositories" in it twice.

2 0
replied on June 20 Show version history

Good catch, thank you. I still have the same error though.

 

Edit: I tried to run this again from the start and it worked. That was simple enough thanks!

0 0

Replies

replied on June 20

Are you using this in a Workflow where your first Web Request Rule is passing the task ID token from the search to the next Web Request Rule to be used in the "%(taskid)" token/variable?  You'll also need to make sure you're passing in the repository ID for use with the "%(repositoryid)" token.  I would add a "Track Token" activity and validate the task ID is correctly getting passed.

0 0
replied on June 20

Hi Andrew, yes all of that was properly set up. I just figured out though that the initial POST call was failing but still returning a 202 response (even though in further inspection in the URL it fails).

202
Date: Thu, 20 Jun 2024 15:28:52 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://api.laserfiche.ca/repository/v2/Repositories/r-00010e/Tasks?taskIds=9e18b8b2-5486-41dc-99e7-69bf34f524f6
odata-version: 4.0
api-supported-versions: 1-alpha, 1, 2-alpha, 2
x-requestid: c50061d1b8c3475ebf410f8e09ebb0ee
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-OperationID: 5cf9ca56a69f29c3bc4d1bc7461948d0
{
  "@odata.context": "https://api.laserfiche.ca/repository/v2/$metadata#Laserfiche.Repository.StartTaskResponse",
  "taskId": "9e18b8b2-5486-41dc-99e7-69bf34f524f6"
}

This is what that looks like but when I go to the "location" URL, I get this response:

{"type":"accessDenied","title":"Error: Invalid or expired access token.","status":401,"instance":"/repository/v2/Repositories/r-00010e/Tasks","operationId":"478c3c68079b435fa28749a2e344df72","errorSource":"Api Server","errorCode":201,"traceId":"00-e4013d8c132147dd521435a9cb3d43e4-66466f83a9298503-00"}

So I am not sure if it is actually succeeding in starting a search task - which would make sense if the second call can not find anything with that task Id. 

 

If that first call is failing, I am not sure why though? The Web Service Connection is working fine and it works on simple calls like a GET call for entry id.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.