[python-gvm] Create_target_response status="400" status_text="Error in host specification"


I’m trying to use python-gvm library to create a target, but I get the message:

<create_target_response status="400" status_text="Error in host specification"/>

Here is the line of code i’m trying to use:

gmp.create_target(name="remote machine", hosts="X.X.X.X", port_list_id="4a4717fe-57d2-11e1-9a26-406186ea4fc5")

It’s a single host, I’ve tried this declaration with /32 and without it, but nothing seems to work

Also, in /var/log/gvm/gvmd.log i find:

event target:MESSAGE:2023-07-28 10h17.51 CEST:1013661: Target could not be created by XXXX
  • port_list_id belongs to “All IANA assigned TCP and UDP”. It’s a minimal setup, in the documentation it does not say there’s any other required field GMP v22.4 - python-gvm
  • Also, here: TechDoc Portal right in the example I’ve seen it only passes a name and a hosts list to create it… so it should basicly work
  • I have also tried to run it without the port_list_id parameter, but same message was reported
  • The user I am using to create it with has “user” role, which has create_target permission among others
  • I have also tried to create it with my admin user just in case, but it reports the same message so its not about permissions aparently

Also, I’m using the community version installed from sources (worked like a charm :ok_hand:)

I do not know what else to try, if anybody could shed some light to this issue I would be very greatful

Thank you!

1 Like


can you just try

gmp.create_target(name="remote machine", hosts=["X.X.X.X"], port_list_id="4a4717fe-57d2-11e1-9a26-406186ea4fc5")



Damn man, I did not fall into that solution!

Makes sense, thank you very much!