RESTAPI Create a model sync task python

Hello,

 

I got a core model with about 40 markets application link.

Each time I create a revision tag, I need to synchronize all application one by one.

 

I'd like to use the new REST API function to create a model sync task  but I got an error and I don't know to fix it.

 

I know that the problem is on data-raw call (Documentation REST API Create a model sync task) but I don't know how to set it up (I've also check on Python Requests documentation)

 

Thank you for your help

 

Regards,

Yohan

 

 

def SynchRevisionTag(vModelID_Target,vModelID_Source,latestRT_ID_Target,latestRT_ID_Source,vToken😞

    SynchRT_URL = 'https://api.anaplan.com/2/0/models/'+vModelID_Target+'/alm/latestRevision'
    header = {'Authorization':'AnaplanAuthToken ' + vToken,'Content-Type':'application/json'}
    data2 =  {'sourceRevisionId':+latestRT_ID_Source'sourceModelId': +vModelID_Source'targetRevisionId':+latestRT_ID_Target}
    r = requests.post(SynchRT_URLheadersheader,data=json.dumps(data2))

    try:
        r.raise_for_status()
    except requests.exceptions.HTTPError as e:
        print("Error: " + str(e))
        exit()

    return r.json()

Best Answer

  • yrignac
    Answer ✓

    Found the solution if some want need it

     

    def SynchRevisionTag(vModelID_Target,vModelID_Source,latestRT_ID_Target,latestRT_ID_Source,vToken😞

        SynchRT_URL = 'https://api.anaplan.com/2/0/models/'+vModelID_Target+'/alm/syncTasks'
        header = {'Authorization':'AnaplanAuthToken ' + vToken,'Content-Type':'application/json'}
        jsondata =  {'sourceRevisionId'latestRT_ID_Source'sourceModelId'vModelID_Source'targetRevisionId'latestRT_ID_Target}
          
        r = requests.post(SynchRT_URLheadersheader,json=jsondata)

        try:
            r.raise_for_status()
        except requests.exceptions.HTTPError as e:
            print("Error: " + str(e))
            print(r.json())
            exit()

        return r.json()