You've got the wrong ID ...
Inside a mxd (ArcGIS 10.3+) you can open the possiblity to fix the IDs on the data frame:
After that you can fix the ID on each layer:
The wish is to set this layer ID's ... but with a python script and not manually.
You see the IDs in a published MapService - the numbers in brackets: