如何调试我的HTTPie或Postman,以便Akamai FastPurge API可以成功调用?

1qczuiv0  于 2023-01-30  发布在  Postman
关注(0)|答案(1)|浏览(141)

我想使用HTTPie或Postman将Akamai FastPurge API的请求剪切在一起,这样我就可以将结构和HTTP请求视为一个整体,目的是构建一个构建相同HTTP请求的Java模块。
我尝试了Akamai* 提供的几个教程,但似乎都不起作用。FastPurge API的凭据在它们自己的edgegrid-file中,我按照Akamai的建议编辑了HTTPie的config.json。无论使用CP代码还是URL,结果都是一样的。API确实具有读写授权,并且凭据可以从文件中正确读取。
我也尝试过使用Postman,但Postman没有集成边缘网格授权,所以我不得不手动操作,不知道它看起来如何。有一个教程介绍如何在Postman中设置Akamai API,但它缺少预请求脚本的关键部分。**

我在HTTPie中收到的错误是:

C:\python>http --auth-type=edgegrid -a default: :/ccu/v3/invalidate/url/production objects:='["https://www.example.com","http://www.example.com"]' --debug

HTTPie 1.0.3-dev
Requests 2.21.0
Pygments 2.3.1
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
c:\python\python.exe
Windows 10

<Environment {
    "colors": 256,
    "config": {
        "__meta__": {
            "about": "HTTPie configuration file",
            "help": "https://httpie.org/doc#config",
            "httpie": "1.0.3-dev"
        },
        "default_options": "['--verbose', '--traceback', '--auth-type=edgegrid', '--print=Hhb', '--timeout=300', '--style=autumn', '-adefault:']"
    },
    "config_dir": "%home",
    "is_windows": true,
    "stderr": "<colorama.ansitowin32.StreamWrapper object at 0x066D1A70>",
    "stderr_isatty": true,
    "stdin": "<_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>",
    "stdin_encoding": "utf-8",
    "stdin_isatty": true,
    "stdout": "<colorama.ansitowin32.StreamWrapper object at 0x066D19D0>",
    "stdout_encoding": "utf-8",
    "stdout_isatty": true
}>
Traceback (most recent call last):
  File "c:\python\lib\site-packages\httpie\input.py", line 737, in parse_items
    value = load_json_preserve_order(value)
  File "c:\python\lib\site-packages\httpie\utils.py", line 7, in load_json_preserve_order
    return json.loads(s, object_pairs_hook=OrderedDict)
  File "c:\python\lib\json\__init__.py", line 361, in loads
    return cls(**kw).decode(s)
  File "c:\python\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "c:\python\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\Scripts\http-script.py", line 11, in <module>
    load_entry_point('httpie==1.0.3.dev0', 'console_scripts', 'http')()
  File "c:\python\lib\site-packages\httpie\__main__.py", line 11, in main
    sys.exit(main())
  File "c:\python\lib\site-packages\httpie\core.py", line 210, in main
    parsed_args = parser.parse_args(args=args, env=env)
  File "c:\python\lib\site-packages\httpie\input.py", line 152, in parse_args
    self._parse_items()
  File "c:\python\lib\site-packages\httpie\input.py", line 358, in _parse_items
    data_class=ParamsDict if self.args.form else OrderedDict
  File "c:\python\lib\site-packages\httpie\input.py", line 739, in parse_items
    raise ParseError('"%s": %s' % (item.orig, e))
httpie.input.ParseError: "objects:='[https://www.example.com,http://www.example.com]'": Expecting value: line 1 column 1 (char 0)

或:

C:\python>http POST --auth-type=edgegrid -a default: :/ccu/v3/invalidate/cpcode/production < file.json
usage: http [--json] [--form] [--pretty {all,colors,format,none}]
            [--style STYLE] [--print WHAT] [--headers] [--body] [--verbose]
            [--all] [--history-print WHAT] [--stream] [--output FILE]
            [--download] [--continue]
            [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
            [--auth USER[:PASS]] [--auth-type {basic,digest,edgegrid}]
            [--proxy PROTOCOL:PROXY_URL] [--follow]
            [--max-redirects MAX_REDIRECTS] [--timeout SECONDS]
            [--check-status] [--verify VERIFY]
            [--ssl {ssl2.3,tls1,tls1.1,tls1.2}] [--cert CERT]
            [--cert-key CERT_KEY] [--ignore-stdin] [--help] [--version]
            [--traceback] [--default-scheme DEFAULT_SCHEME] [--debug]
            [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
http: error: unrecognized arguments: :/ccu/v3/invalidate/cpcode/production

典型的成功响应如下所示:

{
   "httpStatus" : 201,
   "detail" : "Request accepted.",
   "estimatedSeconds" : 420,
   "purgeId" : "95b5a092-043f-4af0-843f-aaf0043faaf0",
   "progressUri" : "/ccu/v2/purges/95b5a092-043f-4af0-843f-aaf0043faaf0",
   "pingAfterSeconds" : 420,
   "supportId" : "17PY1321286429616716-211907680"
}

如果有人能帮助我纠正HTTPie或Postman上的设置,或者给予我Akamai FastPurge HTTP请求的完整结构,这样我就可以跳过HTTPie或Postman的麻烦,我将非常感激。
非常感谢,非常感谢您的帮助!

qxsslcnc

qxsslcnc1#

Postman现在有Akamai edgeGrid授权类型。它接受.edgerc文件的内容。
我在集合上设置它,并让所有调用继承授权。

相关问题