When I try to code the process of publishing web layer, it counters some problems. I can publish it manually, but it alerts the 'ERROR 002901: Sharing related error during geo-processing (Unable to check if service exists. (webtest/Map))' when I ran my python script. It did finish the process of 'Stage Service', and generate the file with the end of '.sd'. Is there any mistakes related to my codes?
I found that the problem happened when I tried to upload service definition. There always be weird problems with arcpy api in this section. I can manually do this in geoprocessing tool but not with the same parameters for python code. (I am sure that the sd file is new for each uploading try)
A week ago I posted about the same problem with very similar code here
I got no responses. I am hoping you get something. I will look at it again sometime today probably.
I'm back looking at this again, thanks to you @JasonHuang I reexamined the setting you used for the server and found a combination that works for me. That in_server arg is absurdly complicated; you have to use different values based on the type of content being shared. Another painful learning moment for me. Maybe I can go answer my own question now!