Problem with API importHar

11 views
Skip to first unread message

Eddy Vanlerberghe

unread,
Jun 22, 2026, 6:33:32 AM (2 days ago) Jun 22
to ZAP User Group
Hi,

For testing I started Zap, launched Firefox for manual testing a website and waited for the main page of the site to load. Then, in the ZAP "History" tab, I selected all entries and then saved the messages via right click "Save as HAR..." to a local file.

Then, after restarting ZAP, I disabled the API key (on an internal test system) to make sure that there is no missing authorization. Next, in a terminal I issued the following command (copied from https://www.zaproxy.org/docs/api/?shell#eximactionimporthar, replaced "string" by the full path to the saved HAR file and host "zap" by "127.0.0.1:8080"):

curl -X GET http://127.0.0.1:8080/JSON/exim/action/importHar/?filePath=/local/path   -H 'Accept: application/json'

which results in:

{"code":"bad_external_data","message":"The external data provided is not valid."}

Within ZAP I see nothing in neither the "History" tab, nor in the sites map. 

A similar result when I try http://127.0.0.1:8080/UI/exim/action/importHar/ in a web browser (presents a web form for uploading a HAR file) Trying to upload the same saved file, I get:

{"code":"bad_external_data","message":"The external data provided is not valid."}

What am I missing here? (I assume that ZAP will recognize a HAR file that is created by ZAP itself?)


Simon Bennetts

unread,
Jun 23, 2026, 8:22:02 AM (yesterday) Jun 23
to ZAP User Group
Hiya,

I would expect that to work.
Are there any errors in the zap.log file?

Cheers,

Simon

Eddy Vanlerberghe

unread,
Jun 23, 2026, 8:50:45 PM (16 hours ago) Jun 23
to ZAP User Group
Hm, thanks for that information: it allowed my to solve the problem.

For some reason the HAR file was overwritten with just the text "- node: Sites". So I tried again, this time making sure that the input file was not changed between saving and reading. The import worked as expected. Most likely I used an export action before hitting the right import action.
Reply all
Reply to author
Forward
0 new messages