<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 501 error with Publish using web_api/publish in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213586#M8495</link>
    <description>&lt;P&gt;Thanks for the reply, but I'm unsure what I should put to the payload of the function &lt;STRONG&gt;Publish.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If I put the current login session UID - the same error 501&amp;nbsp;&lt;SPAN&gt;{'code': 'not_implemented', 'message': 'Publishing other than current session is not implemented'}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I remove uid from the function - get&amp;nbsp; 400 {'code': 'generic_err_invalid_syntax', 'message': 'Payload is empty'}&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Documents said:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Session unique identifier. Specify it to publish a different session than the one you currently use.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2024 07:11:36 GMT</pubDate>
    <dc:creator>Larionov_Ivan</dc:creator>
    <dc:date>2024-05-08T07:11:36Z</dc:date>
    <item>
      <title>501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213465#M8493</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I'm trying to use 'web_service' to publish changes on the management server (81.20). I'm following the format in the 'Management API Reference' (&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/#web/publish~v1.8.1%20)" target="_blank" rel="noopener"&gt;https://sc1.checkpoint.com/documents/latest/APIs/#web/publish~v1.8.1%20)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Receive error with &lt;STRONG&gt;publish&lt;/STRONG&gt; function:&amp;nbsp;{'code': 'not_implemented', 'message': 'Publishing other than current session is not implemented'}&lt;/P&gt;&lt;P&gt;My Python code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_sid():
    r = requests.post(
        url=f"{chkpt['url']}/web_api/login", 
        headers={"Content-Type" : "application/json"},
        json={'api-key' : chkpt['api-key']},
        verify=False
    )
    r.raise_for_status()
 
    return r.json()
 
def set_session(name, description, comment):
    r = requests.post(
        url=f"{chkpt['url']}/web_api/set-session",
        headers=headers,
        json={
            "new-name" : name,
            "description" : description,
            "comments" : comment},
        verify=False
    )
    r.raise_for_status()
 
    return r.json()
 
def publish(uid):
    r = requests.post(
        url=f"{chkpt['url']}/web_api/publish",
        headers=headers,
        json={'uid' : uid},
        verify=False
    )
    r.raise_for_status()
 
 
### Full scenario
 
# Login
headers = {
        "Content-Type" : "application/json",
        "X-chkp-sid" : get_sid()['sid'] 
    }
 
# Set name/description/comment for session
new_session = set_session(name, description, comment)
 
# Add new hosts to some group
create_new_objects()
 
# Publish changes
publish(new_session['uid'])
 
# install policy
install_policy(policy_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 10:48:33 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213465#M8493</guid>
      <dc:creator>Larionov_Ivan</dc:creator>
      <dc:date>2024-05-07T10:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213542#M8494</link>
      <description>&lt;P&gt;To publish the current session, you do not need to pass a uid to the publish function.&lt;BR /&gt;In fact, that's exactly what the error is saying (this function is not implemented).&lt;BR /&gt;The session that will be published is the one passed with X-chkp-sid in the HTTP headers.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/37502"&gt;@Omer_Kleinstern&lt;/a&gt;&amp;nbsp;if publishing another session isn't implemented, shouldn't the docs reflect this?&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 22:43:34 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213542#M8494</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2024-05-07T22:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213586#M8495</link>
      <description>&lt;P&gt;Thanks for the reply, but I'm unsure what I should put to the payload of the function &lt;STRONG&gt;Publish.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If I put the current login session UID - the same error 501&amp;nbsp;&lt;SPAN&gt;{'code': 'not_implemented', 'message': 'Publishing other than current session is not implemented'}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I remove uid from the function - get&amp;nbsp; 400 {'code': 'generic_err_invalid_syntax', 'message': 'Payload is empty'}&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Documents said:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Session unique identifier. Specify it to publish a different session than the one you currently use.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 07:11:36 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213586#M8495</guid>
      <dc:creator>Larionov_Ivan</dc:creator>
      <dc:date>2024-05-08T07:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213658#M8496</link>
      <description>&lt;P&gt;The documentation is correct insofar as this is the intent of passing a uid, specifically publishing a DIFFERENT session from the one specified as part of the X-chkp-sid header.&lt;BR /&gt;However, as the error message clearly states, this is not currently implemented.&lt;BR /&gt;Which means you should not pass uid as part of your payload, but rather an empty JSON string: { }&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 14:32:33 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213658#M8496</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2024-05-08T14:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213663#M8497</link>
      <description>&lt;P&gt;I recommend looking at the examples in the API guide if something is unclear.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/index.html?#web/publish~v1.9.1%20" target="_blank"&gt;https://sc1.checkpoint.com/documents/latest/APIs/index.html?#web/publish~v1.9.1%20&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From API login command reference, it returns uid in the answer for the following:&lt;/P&gt;
&lt;TABLE class="table"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="param_key"&gt;&lt;SPAN class="blue"&gt;uid&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD class="param_value"&gt;string&lt;/TD&gt;
&lt;TD class="param_description"&gt;&lt;SPAN class="description to_check_for_rewrite"&gt;Session object unique identifier. This identifier may be used in the discard API to discard changes that were made in this session, when administrator is working from another session, or in the 'switch-session' API.&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 15:31:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213663#M8497</guid>
      <dc:creator>Amir_Senn</dc:creator>
      <dc:date>2024-05-08T15:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213670#M8498</link>
      <description>&lt;P&gt;You need to include an empty JSON object. I just tested:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;➜  PublishTest&amp;gt; curl -ks "https://${TestMgmt}/web_api/login" --header "Content-Type: application/json" -d '{"user":"admin","password":"1qaz!QAZ","read-only":false}' &amp;gt;session1.txt
Session1Uuid=$(jq '.uid' session1.txt)
Session1Sid=$(jq '.sid' session1.txt | tr -d '"')
curl -ks "https://${TestMgmt}/web_api/login" --header "Content-Type: application/json" -d '{"user":"admin","password":"1qaz!QAZ","read-only":false}' &amp;gt;session2.txt
Session2Uuid=$(jq '.uid' session2.txt)
Session2Sid=$(jq '.sid' session2.txt | tr -d '"')

➜  PublishTest&amp;gt; curl -k "https://${TestMgmt}/web_api/publish" --header "X-Chkp-Sid: ${Session1Sid}" --header "Content-Type: application/json" -d "{\"uid\":${Session1Uuid}}"
{
  "code" : "not_implemented",
  "message" : "Publishing other than current session is not implemented"
}

➜  PublishTest&amp;gt; curl -k "https://${TestMgmt}/web_api/publish" --header "X-Chkp-Sid: ${Session1Sid}" --header "Content-Type: application/json" -d "{\"uid\":${Session2Uuid}}"
{
  "code" : "not_implemented",
  "message" : "Publishing other than current session is not implemented"
}

➜  PublishTest&amp;gt; curl -k "https://${TestMgmt}/web_api/publish" --header "X-Chkp-Sid: ${Session1Sid}" --header "Content-Type: application/json"
{
  "code" : "generic_err_missing_session_id",
  "message" : "No query parameters are found"
}

➜  PublishTest&amp;gt; curl -k "https://${TestMgmt}/web_api/publish" --header "X-Chkp-Sid: ${Session1Sid}" --header "Content-Type: application/json" -X POST
{
  "code" : "generic_err_invalid_syntax",
  "message" : "Payload is empty"
}

➜  PublishTest&amp;gt; curl -k "https://${TestMgmt}/web_api/publish" --header "X-Chkp-Sid: ${Session1Sid}" --header "Content-Type: application/json" -d "{}"
{
  "task-id" : "01234567-89ab-cdef-ace5-5d8aa277909b"
}&lt;/LI-CODE&gt;
&lt;P&gt;Note that a call to /publish with just the POST method but no body at all returns the "Payload is empty" error.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 16:10:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213670#M8498</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2024-05-08T16:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: 501 error with Publish using web_api/publish</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213671#M8499</link>
      <description>&lt;P&gt;Yes, and the fact that an empty JSON string must be sent is clearly shown in the example.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 16:19:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/501-error-with-Publish-using-web-api-publish/m-p/213671#M8499</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2024-05-08T16:19:04Z</dc:date>
    </item>
  </channel>
</rss>

