Posting Policies with the Cocoa SDK

jtratta
New Contributor III

Hello,

I have had a lot of success adding computers via the Cocoa SDK. I'm having some problems putting polices with it. I can get them with no problems. Perhaps someone here knows the answer? Here's how I'm sending the data.

[commClient putWithURL:JssAddr JSSUserName:JssUser JSSPassword:JssPass JSSPath:[NSString stringWithFormat:@"/JSSResource/policies/id/%@", policyID] JSSCommDelegate:self PUTData:[newPolicy XMLData]];

'newPolicy'(NSXMLDocument) is a modified version of a policy from another JSS of the same version. I'm just changing the ID to insert it onto the other server.

I get an error like: "The server has not found anything matching the request URI"

Thanks, Jason

1 REPLY 1

jtratta
New Contributor III

I was able to sort this out with help from JAMF. You can post (instead of put) policy xml without an ID number, the JSS will assign one. This doesn't seem possible if you're looking at the API...so perhaps there are other hidden gems in there? Here's the working cocoa call:

[commClient postWithURL:JssAddr JSSUserName:JssUser JSSPassword:JssPass JSSPath:[NSString stringWithFormat:@"/JSSResource/policies"] JSSCommDelegate:self PUTData:[newPolicy XMLData]];

One additional note, the post will fail if the category id's do not match. You'll need to match the category name strings and map the ids. Since the servers auto generate an ID number for them, it's highly unlikely the Category ID's will match server to server. This all assumes of course you are moving raw XML from on server to the next.