batchql icon indicating copy to clipboard operation
batchql copied to clipboard

Error when adding a header

Open alihussainzada opened this issue 8 months ago • 0 comments

I was getting the bellow error:

[ali@koalasec batchql]$ python3 batch.py -e https://api.target.com/graphql/ --header "Api-Key: 999999999"
Traceback (most recent call last):
  File "/home/ali/tools/batchql/batch.py", line 28, in <module>
    point_index = header.find(":")
                  ^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'find'

However i was able to solve the issue by modify the code to:

if args.header:
    for header in args.header:
        if isinstance(header, list):  
            header = header[0] 

        if ":" in header:  # Ensure the format is correct
            point_index = header.find(":")
            header_dict[header[:point_index].strip()] = header[point_index+1:].strip()
        else:
            print(f"Invalid header format: {header}")

instead of:

if args.header:
  for header in args.header:
    point_index = header.find(":")
    header_dict[header[:point_index].strip()] = header[point_index+1:].strip()

alihussainzada avatar Feb 19 '25 09:02 alihussainzada