Create new department using Postman
is there a way using Postman to test api settings and create a new department? I would do this in the sandbox for testing purposes.
Asked by Kirk McCoskey
on Wed 4/13/22 1:13 PM
Sign In to leave feedback or contribute an answer
Answer (1)
This answer has been marked as the accepted answer
Mark Sayers
Wed 4/13/22 1:50 PM
Hello Kirk,
There is an API endpoint to facilitate creating new Accounts/Departments using the TDWebApi/api/accounts endpoint. To make that take place in sandbox, simply add SB in front of the TDWebApi part of the endpoint URL like so: https://yourdomainhere/SBTDWebApi/api/accounts
No feedback
so I've done a lot of testing in Postman and I've used the enpoints as you describe, but how do I get Postman to actually create the account? it looks like I'm able to login, but I can't seem to get any results.
- Kirk McCoskey
Wed 4/13/22 1:53 PM
I'm not sure if I fully understand the question, but I'll attempt to offer an answer:
If you are authenticating into the API ok, and getting your bearer token, you need to include that bearer token in your header of all of your subsequent calls to the API endpoints. That header should look like so:
authorization: Bearer tokenstringgoeshere
Then for that create endpoint you would make a POST call to https://yourdomain/SBTDWebApi/api/accounts formatted as a json object, and including all of the required properties as stated at https://app-eus.teamdynamix.com/TDWebApi/Home/type/TeamDynamix.Api.Accounts.Account and then as many of the other Editable objects as you wish to include values for. - Mark Sayers Wed 4/13/22 2:10 PM
If you are authenticating into the API ok, and getting your bearer token, you need to include that bearer token in your header of all of your subsequent calls to the API endpoints. That header should look like so:
authorization: Bearer tokenstringgoeshere
Then for that create endpoint you would make a POST call to https://yourdomain/SBTDWebApi/api/accounts formatted as a json object, and including all of the required properties as stated at https://app-eus.teamdynamix.com/TDWebApi/Home/type/TeamDynamix.Api.Accounts.Account and then as many of the other Editable objects as you wish to include values for. - Mark Sayers Wed 4/13/22 2:10 PM
If you're having issues getting the call to go through specifically, it might be best to move this to a Support ticket so you can provide the Body and headers that you're sending when you attempt to make a call to create an account, and a screen shot of the resulting response from the endpoint.
- Mark Sayers
Wed 4/13/22 2:11 PM
I can see from your comments, I'm not really setting this up correctly, so I'm hoping for an example that gets me to the point that I'm doing the authentication correctly. I've not yet gotten a JSON response. I think I see a bearer token, but since my response doesn't come back in a JSON format, I'm assuming I don't have my authentication setup correctly, do you have a sample I could build off of. if that doesn't work then I'd get a support ticket in to get help there.
- Kirk McCoskey
Wed 4/13/22 2:33 PM
If you make the auth call and get the bearer token, that means you *did* successfully get signed in through the API. So put the token in your header of your call to the account creation endpoint, as mentioned, and make sure you are *passing* a json formatted Body in that call, containing any relevant properties that you wish to include. It would look something like this for the body of the call:
{"Name": "NameGoesHere",
"ParentID": IDnumberofparentAcctDept,
"IsActive": True,
}
Etc. for any additional fields needed. - Mark Sayers Wed 4/13/22 3:19 PM
{"Name": "NameGoesHere",
"ParentID": IDnumberofparentAcctDept,
"IsActive": True,
}
Etc. for any additional fields needed. - Mark Sayers Wed 4/13/22 3:19 PM
I did end up with the solution to my issue.
I did NOT put any private information in this comment entry.
here are the sample values and places I put those values.
I placed the full URL https://support.mydomain.com/SBTDWebApi/api/auth/loginadmin in the post entry
then I put in the request header Content-Type value of application/json;charset=utf-8
then I used the JSON pay load of
{
"BEID":"456-95AB....etc",
"WebServicesKey":"123-303D.....etc"
}
in the request body and that gave me the Bearer token value back in the response body so it successfully logged in. - Kirk McCoskey Tue 4/19/22 1:56 PM
I did NOT put any private information in this comment entry.
here are the sample values and places I put those values.
I placed the full URL https://support.mydomain.com/SBTDWebApi/api/auth/loginadmin in the post entry
then I put in the request header Content-Type value of application/json;charset=utf-8
then I used the JSON pay load of
{
"BEID":"456-95AB....etc",
"WebServicesKey":"123-303D.....etc"
}
in the request body and that gave me the Bearer token value back in the response body so it successfully logged in. - Kirk McCoskey Tue 4/19/22 1:56 PM
I put in the URL https://support.mydomain.com/SBTDWebApi/api/accounts in the post entry
Then I placed the bearer token value in the request header in the form of 'Bearer ' + {{token}}
and used the payload of
{
"Name":"test 01",
"Code":"AAAB"
}
in the request body and that added the account with the name of test 01 in the sandbox I was trying to add the account to.
So the first request I logged in and got the bearer token value and the second request I authenticated with the bearer token value and added the account with that JSON payload.
my 2 request items were in a collection and I ran the collection to get both tasks done. - Kirk McCoskey Tue 4/19/22 2:06 PM
Then I placed the bearer token value in the request header in the form of 'Bearer ' + {{token}}
and used the payload of
{
"Name":"test 01",
"Code":"AAAB"
}
in the request body and that added the account with the name of test 01 in the sandbox I was trying to add the account to.
So the first request I logged in and got the bearer token value and the second request I authenticated with the bearer token value and added the account with that JSON payload.
my 2 request items were in a collection and I ran the collection to get both tasks done. - Kirk McCoskey Tue 4/19/22 2:06 PM