Skip to content

Error when adding a header #5

Open
@alihussainzada

Description

@alihussainzada

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions