Creating new changes via Restful API

Good evening community,

I'm extremely new to working with service manager and I hate to even have to come and ask this, but I'm stuck with how to create new changes. I keep getting a 400 error with no other information. The snippet of code I' m using is below. 

Any and all help is greatly appreciated. 

requireInfo = {'Change':
                    {'BranchChiefPin' : '111111',
                     'DivDirPin''123456',
                     'ProjectInfrastructure''project',
                     'Standalone''YES',
                     "close": {"ClosureCode"'0'},
                     'desciption.structure' : {'Description' : 'Testing'},
                     'header' : {'AssignmentGroup' : 'group',
                                 'BriefDescription' : 'Testing',
                                 'Category' : 'RFC',
                                 'InitiatedBy' : {'Contact': {'ContactName''me' , 'FullName' : 'me'}},
                                 'Phase' : 'RFC assessment',
                                 'PlannedStart' : '2024-01-01T14:00:00+00:00',
                                 'PlannedEnd' : '2024-01-03T14:00:00+00:00',
                                 'Reason' : 'Testing',
                                 'RiskAssessment' : '1',
                                 'Status' : 'initial',
                                 'Subcategorey' : 'Open Systems'},
                    'middle' : {'Location' : 'All',
                                'PrimaryCI''SECURITY ARCHITECTURE - MAIN',
                                'WIKIUpdate' : 'NO'},

                },
                'Messages' : [],
                'ReturnCode' : 0
}

url = '.../SM/9/rest/changes' (url redacted)
headers = {'User-Agent''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'}
r2 = requests.post(urlheaders=headersjson=requireInfoauth=(user_name,user_pass), verify=False)
  • 0  

    Hi Dillon

    Would you please to provide the log file about it?

    Thanks

  • 0  

    The URL should be like:  ../SM/9/rest/changes/1111/action/create
    (The '1111' is just a placeholder)

  • 0

    you get no answer if you have the wrong url.

    I suggest to try curl -v (verbose) to get more information on requests.

    GET (read):
    curl -s -H "Authorization: Basic PutYourBase64Encoded<Username:Password>Here" "myBaseUrl/SM/9/rest/<MyChangePath>/<ChangeId>" > myDataFile.txt

    Learn about the structure from this.

    POST (Create)

    curl -v -X POST -H "Authorization: Basic PutYourBase64Encoded<Username:Password>Here" -H "Content-Type: application/json" "myBaseUrl/SM/9/rest/<MyChangePath>" --data-binary @myDataFile.txt

    PUT (Update)

    curl -v -X PUT -H "Authorization: Basic PutYourBase64Encoded<Username:Password>Here" -H "Content-Type: application/json" "myBaseUrl/SM/9/rest/<MyChangePath>/<ChangeId>" --data-binary @myDataFile.txt