I need to upload response page

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

I need to upload response page

I am currently in the process of planning to upload a custom webpage to my Palo Alto device. However, I would like to automate this process through an API call. I have the HTML content for the webpage stored in a variable and I would like to upload it to the following path. Any references or suggestions in this regard would be greatly appreciated.

The manual update path is as follows:

Device -> Response Page -> URL Filtering and Category Match Block Page

There is already one predefined file in place, so if there's a way to update that without uploading a new file, that would also be acceptable for me.

I would be very grateful for any suggestions or assistance. Thank you in advance.

 

 

6 REPLIES 6

Cyber Elite
Cyber Elite

Hi @Indranil-Chowdhury ,

 

Here is an example for the application block page.  https://live.paloaltonetworks.com/t5/api-articles/modify-response-pages-from-xml-api/ta-p/62167

 

You would only need to modify the syntax to do the same for the URL block page.

 

For drive-by browsers, here is a cool doc on creating custom response pages.  https://live.paloaltonetworks.com/t5/blogs/tips-amp-tricks-how-to-customize-your-response-pages/ba-p...  That's where I found the example above.

 

Thanks,

 

Tom

Help the community: Like helpful comments and mark solutions.

Thankyou so much for your response.

I am preparing the script for uploading the HML page to box under url category.
I need help to understand where i am going wrong here. I am sharing code below.

 

$deviceUrl = "https://1.2.3.4:4443/esp/restapi.esp?key=" + $retrieve_token

 

$htmlContent = @"
<!DOCTYPE html>
<html>
<head>
<title>Custom Response Page</title>
</head>
<body>
<h1>This is a custom response page</h1>
<p>Custom content for the response page goes here...</p>
</body>
</html>
"@

 

# Convert the HTML content to Base64
$htmlContentBase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($htmlContent))

 

# Define the XML API request body with the encoded HTML content
$xmlRequestBody = @"
<request>
<system>
<response-pages>
<entry name="Application-block-page">
<html-content>$htmlContentBase64</html-content>
</entry>
</response-pages>
</system>
</request>
"@

 

$response1 = Invoke-RestMethod -Uri $deviceUrl -Method Post -Body $xmlRequestBody -ContentType "application/xml"

Cyber Elite
Cyber Elite

What error are you getting?

Help the community: Like helpful comments and mark solutions.

Thankyou for your response.

I am not sure about the error but webpage is not uploading to the device. and also attaching the output for $response1

Cyber Elite
Cyber Elite

Hi @Indranil-Chowdhury ,

 

If you are not able to discern the error in your code output, I can't help you.  I did provide you with the XML URL to upload a page, which you requested.

 

You could try to use curl or Postman to verify the URL works outside of your script.

 

Thanks,

 

Tom

Help the community: Like helpful comments and mark solutions.

can you please help me with curl command to upload the page. It will be helpful.

  • 1406 Views
  • 6 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!