[API] - Python - Activities Extraction

Comments

4 comments

  • Avatar
    Tim Smith

    David (if you're still around):

    We're trying to get your snippet above to run but getting a KeyError evidently related to this line:

                       CheckTotalRows = int(response.headers['X-Pw-Total'])

    It doesn't look like X-Pw-Total is being returned in the header response.  If you have a moment to try, does this snippet still run for you?

    (Or Rachel, if you have any advice, since you pointed us here.)

    Thanks,

    ts

  • Avatar
    Rémi DE SAIGNES

    Hello TIm,

    Well, I am still around ( and still experiencing difficulties with activities :) but Rachel@Copper is looking at it ).

    As far as i understand it, the X-PW-TOTAL is returned on search API requests to tell you how much records it returned.

    i.e : an API call /activities/<Specific ID> will not get it, a call /activities/search will do.

    For now there is still problems with searchs ending up with time out responses  ( status 500, "message": "Request ran for longer than 25000ms" )... in those cases, the property isn't available inducing the script to crash.

    I actually does not have an answer to those errors as they are coming from Copper side.

    ( As far as i can judge for now )

    For a clean script exit you can trap the response status just after the

    response = requests.post(url, data=payload, headers=headers)

    If you have any other questions, i'll try my best to answer :)

    @Copper : please correct me if i'm saying crap :p

    P.S : Have fun using this lovely API tool :D

    P.S 2 : Using Postman can help you with some basic API calls structure and all.

    P.S 3 : As english is not my native language please excuse my mistakes, bad conjugation tense and so on :p

  • Avatar
    Tim Smith

    Rémi:

    Many thanks for this.  Will keep experimenting.  Also talking to Rachel :-)

    Cheers,

    ts

  • Avatar
    Rémi DE SAIGNES

    Hello Tim,

         I updated the first post with the last version of our scripts.

         => As suggested by Rachel, added the "full_result" in the payload.

         => Added the list of activities to be sure to get all of them in the returned recordset.

         => Added the response error handle to avoid script crash.

        Should be working fine now.

    Best Regards,

    David.

Please sign in to leave a comment.