Does anyone have one of these they can share that makes use of the new authorization?
@Nik_B Download the Postman app, and you can use the XMLRPC documentation to build the Python code for you.
Iâm not a Python developer, but using Postman I was able to generate this code:
import http.client
conn = http.client.HTTPSConnection("api.infusionsoft.com")
payload = "<?xml version=\"1.0\"?>\r\n<methodCall>\r\n <methodName>SearchService.getSavedSearchResultsAllFields</methodName>\r\n <params>\r\n <param>\r\n <value><string>SAK_GOES_HERE</string></value>\r\n </param>\r\n <param>\r\n <value><int>SAVED_SEARCH_ID</int></value>\r\n </param>\r\n <param>\r\n <value><int>USER_ID</int></value>\r\n </param>\r\n <param>\r\n <value><int>0</int></value>\r\n </param>\r\n </params>\r\n</methodCall>"
headers = {
'X-Keap-API-Key': 'SAK_GOES_HERE',
'Content-Type': 'application/xml'
}
conn.request("POST", "/crm/xmlrpc/v1", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Search for these strings and replace them w/ your values:
SAK_GOES_HERE = Your Keap SAK
SAVED_SEARCH_ID = The numerical ID of the saved search
USER_ID = The user id
https://developer.keap.com/docs/xml-rpc/#search-retrieve-a-complete-report-from-a-saved-search
All of the request details are listed here.
To get the search Id, I use the inspector on the browser to find the Id relevant saved search that I want.
thank you marion! i also need the piece to get the oauth token
I think I see the confusion. When they announced the sunsetting for the legacy API key, the documentation said to use the header: X-Keap-API-Key with the PAK or SAK.
When looking at the latest documentation itâs showing the âAuthorizationâ header passing âBearer ProvideYourKeyHereâ as the value.
So the code I provided will work, or you can update the header and replace it to match the current docs:
âAuthorizationâ: âBearer ProvideYourKeyHereâ,
https://developer.infusionsoft.com/pat-and-sak/
The XMLRPC doesnât use the OAuth authentication. You just need to create a Service Account Key to replace the old Legacy API key. If youâre already using the the OAuth API there isnât a new authorization method, so everything âshouldâ still work.
got it. yes that is confusing on the site. ty
It accepts both headers right now. We have standardized on using the Authorization header going forward to support better SDK generation which will be coming in the future.