Using API to update Employees

Greetings!
I've been following along and researching on how to update the employee listing in Expensify.
Is there any way I can modify the code so that I can embed what needs to be updated directly into the code without having to reference the physical file?
I'm currently running into an issue with this error:
{"responseMessage":"Multipart data is missing","responseCode":410}
When I switch the Headers to multipart/form-data it returns a non-error.
Can anyone advise? Thank you!
Answers
-
Hey there, @Peter_Lay! Thanks for writing in! Would you be able to reply with an example of your API request so we can have look? Be sure to omit the
partnerUserID
andpartnerUserSecret
! -
"credentials": {
"partnerUserID": "REMOVED",
"partnerUserSecret": "REMOVED"
},
"inputSettings": {
"type": "employees",
"policyID":"PolicyID",
"fileType": "csv"}
}
-D 'data=@C:\Documents\Expensify\Expensify712020'
@John Schuster Thank you for your response!
-
@Peter_Lay is the file that you are calling a CSV? I don't see an extension at the end of the file name.
-
Apologies, I've tried it with and without. The error message still persists.
Is there a way that I can pass the content of the file by explicitly stating it in the script?
-
Ah! One more thing!
Coming from our API documentation, it looks like the
-D
option may not be the right option.Here's what the docs indicate:
The
data
parameter has to use themultipart/form-data
content-type. With curl, use the-F
option to pass it.Can you try using the
-F
option and ensuring the file extension is CSV? -
Yes, I've tried using both -F and -D
Both yielded the same result.
-
Apologies - the error that I'm receiving beyond that looks a bit odd:
<html>
<head>
<title>Error</title>
<style>
body {
font-family: Arial;
}
pre {
padding: 5px;
background-color: #ddd;
border-top: 2px solid #999;
}
</style>
</head>
<body>
<h1>An error occurred</h1>
<pre>Internal Server Error</pre>
</body>
</html>
-
Hey @Peter_Lay, a few things looked a bit out of place when I reviewed your original request. I've modified your initial request to match what's laid out in our docs. Can you give this a try?
```
curl -X POST 'https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations' \
-H 'Expect:' \
-F 'requestJobDescription={
"type": "update",
"credentials": {
"partnerUserID": "REMOVED",
"partnerUserSecret": "REMOVED"
},
"inputSettings": {
"type": "employees",
"policyID":"PolicyID",
"fileType": "csv"
}
}' \
-F 'data=@C:\Documents\Expensify\Expensify712020.csv'
```
-
Hi John,
I'm getting a different message now:
<html>
<head>
<title>Page not found</title>
</head>
<body>
<h1>Page not found</h1>
</body>
</html>
Do you know if the file can be stored locally to then be passed through this API? Or does the file need to be stored somewhere in Expensify already?
-
Yep! The file can be stored locally, so that shouldn't be the issue.
Hm, by any chance is the file missing any of the required CSV columns?
The documentation indicates that, at a minimum, your CSV must include columns for
EmployeeEmail
,ManagerEmail
, andAdmin
. -
Hi John,
Yes, the file currently has 3 columns denoted as:
EmployeeEmail, ManagerEmail, Admin
Email, Email, false
I currently have it in excel but saved in a csv format
Thank you for your help thus far,
Peter. L.
-
Thanks for confirming that!
So, that
Page Not Found
error indicates that something is up with the request. I know you've already sent your request along, but would you mind sending it along one more time?Can you confirm the email address that generated the partnerUserID and partnerUserSecret? Also, can you confirm that you are including a Policy ID in your request?
-
Hi John,
I was the one who generated the partnerUserId and PartneruserSecret, so it should be tied to my email.
I can also confirm that the Policy ID is listed, we have a test policy in our instance, so we are trying to update an email from X to Y to test out the functionality before we add more to it.
Regarding sending over the request, are you asking me to send the payload over one more time?
Thanks!
Peter. L.
-
Yep! Please send over the full payload again, omitting the usual secret credentials.
-
https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations
-H 'Expect:' /
-F 'requestJobDescription={
"type": "update",
"credentials": {
"partnerUserID": "REMOVED",
"partnerUserSecret": "REMOVED"
},
"inputSettings": {
"type": "employees",
"policyID":"2A29DC86CCE1BACE",
"fileType": "csv"
}
}' /
-F 'data=@C:/Users/laypeter/Documents/Expensify/Expensify712020.csv'
-
Aha! I've just figured it out. In order for you to update users on a policy, the account from which you are sending the request needs to be a policy admin on the policy.
I took a look at that policy, and it doesn't look like the email associated with your Expensify account is a policy admin – can you either have your account promoted to a policy admin, or have the policy admin generate API credentials and use those for the request?
-
Gotcha!
That makes sense, so using my current secret I'm only able to extract Expense data but not make any modifications to Expensify.
To rectify this issue, I need to generate the secretUserID/Secret by using the policy Administrator or make my account a policy Admin.
Coding wise, it's fine?
Thanks for your help thus far,
Peter. L.
-
Yep! The payload looks fine at this point!
You're correct! The changes that you are trying to make are changes that a policy admin would be able to make on the People Table of the policy, so in order for you to make those changes using the API, your Expensify account would need policy admin permissions on the policy you're trying to change.
Does that make sense?
-
Yes this makes perfect sense.
I will go ahead and make those changes, being a policy admin isn't the same as being a co-pilot correct?
-
Hi @Peter_Lay - That's correct. A Copilot is a feature within Expensify that allows users to give another user access to their account. This feature is managed at the account-level under Settings > Account > Account Details.
A Policy Admin is a user role. This user role is considered the manager of a policy as they're the only user that has access to the policy's settings. User roles are managed on the people table under Settings > Policies > Group > [Policy Name] > People.
I hope that clears things up!
-
Hi @John Schuster ,
I've updated the user that generated the PartnerID/PartnerSecret to be a policy Admin but the error that I'm receiving is still persisting:
<html>
<head>
<title>Page not found</title>
</head>
<body>
<h1>Page not found</h1>
</body>
</html>
Can you please advise?
Thanks!
Peter. L.
-
Hey there @Peter_Lay!
Hm, when we see "Page Not Found", it typically means the request itself is wrong. Given that you've already shared the payload here, I think the only way we can move this further along would be if you were to share some specifics on the payload. That said, I wouldn't feel comfortable with you sharing either the partnerUserID or partnerUserSecret here in the forum, so I think we may need to take this to Concierge.
Can you please reach out to [email protected] and reference this thread from the community? I'd like to take a look at the entire request (including the omitted bits from before).
-
Hi John,
I was able to figure it out. The script was indeed correct. I was just putting some of the blocks in the wrong parts of postman. I was able to update the employee list by modifying their emails.
Thank you very much for your help!
Peter. L.
-
That's great news, @Peter_Lay! I'm glad to hear you got it sorted! 🎉