500 Internal server error with POST api/tasks

500 Internal server error with POST api/tasks

Anonymous
Not applicable
52,375 Views
5 Replies
Message 1 of 6

500 Internal server error with POST api/tasks

Anonymous
Not applicable

When I’m trying to import Tasks using the POST /api/tasks I’m being returned an internal server error.

 

I’m using the following: Postman to perform POST-call.

URL: https://bim360field.eu.autodesk.com/api/tasks?ticket={{ticket}}&project_id={{project_id}}

JSON-body:

 

 

[
    {
        "id": "71bde28e-c6b5-4bd0-8bf8-c2b47f3c41dc",
        "name": "TestName",
        "template": false,
        "identifier": "TSK-0026",
        "description": "TestDescr",
        "status": "New",
        "scheduled_at": "2017-09-06 15:38:00 +0200",
        "location_detail": null,
        "send_reminders": false
    }
]

 

I have tried both passing the data in the body of the request as in the url.

 

Response

Status: 500

 

Question

What am I doing wrong with this request?

0 Likes
Accepted solutions (1)
52,376 Views
5 Replies
Replies (5)
Message 2 of 6

mikako_harada
Community Manager
Community Manager

Hi, 

 

I just tried.  It works for me. 

 

Possible place to check: 

 

  • id is correct for existing task. 
  • no id needed for creating a new one. 
  • make sure your string does not have invisible characters, such as tab and carriage return. 

For debugging purpose, I usually use tools like described here: 

 

https://fieldofviewblog.wordpress.com/2016/09/13/troubleshooting-tips-making-rest-calls/

 

 


Mikako Harada
Developer Technical Services
0 Likes
Message 3 of 6

Anonymous
Not applicable
Accepted solution

Apparently it's not part of the body of the POST request. This is not quite explained in the API documentation. For future reference, my problem was solved by switching the JSON array from the body to the URL. Using the body for such calls would have made more sense BTW.

 

When adding a piece of JSON, don't forget to percent-encode this part.

 

Working URL:

 

https://bim360field.eu.autodesk.com/api/tasks?ticket={{ticket}}&project_id={{project_id}}&tasks=%5B%...

0 Likes
Message 4 of 6

Anonymous
Not applicable

500 internal server errors provide an incredibly irritating experience for WordPress developers and users. On top of that, this issue doesn’t give any clue, reason, or solution. Therefore, it is often rectified through hit and trial methods as mentioned above. I hope that some of my pointers may prove beneficial and will, in the end, reduce your labor and frustration.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi,

step 1: define your variables in JSON format ( in Pre-request Script)

    eg: 

         var sender = request.data["sender"];
         var recipient = request.data["recipient"];
         var amount = request.data["amount"];
step 2: Go to Body -> raw. Add your variables.
    eg:
        
{
    "sender" : "5543524dfb694eddb5f7b339d5c86ddf",
    "recipient" : "some_one_else",
    "amount" : 34
}
Remember, you have to choose the JSON format here.
step 1step 1step 2step 2
 
0 Likes
Message 6 of 6

c.schoneveld
Advocate
Advocate

@mikako_harada 

I also want to create a form in acc, from power automate. All of my other API get calls work only the post form action gives me an internal server error.. 500

0 Likes