LoginSignup
0
0

More than 1 year has passed since last update.

Httpie: GitHub で GraphQL を使う

Posted at

こちらのプログラムを Httpie で書き換えました。
Curl: GitHub で GraphQL を使う

プログラム

http_name.sh
#! /bin/bash
#
#	http_name.sh
#
#							   Apr/15/2022
# 
ACCESS_TOKEN="ghp_*********"
#
URL="https://api.github.com/graphql"
#
http POST ${URL} "Authorization: Bearer "${ACCESS_TOKEN} @query.json
#
query.json
{
 "query": "query { user(login: \"ekzemplaro\") {name location url}}"
}

実行結果

$ ./http_name.sh 
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Sat, 15 Apr 2023 07:59:23 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Transfer-Encoding: chunked
Vary: Accept-Encoding, Accept, X-Requested-With
X-Accepted-OAuth-Scopes: repo
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v4
X-GitHub-Request-Id: B3C2:17B3:23AEA8:267D93:643A595A
X-OAuth-Scopes: admin:org, admin:public_key, delete:packages, repo, workflow, write:packages
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996
X-RateLimit-Reset: 1681548817
X-RateLimit-Resource: graphql
X-RateLimit-Used: 4
X-XSS-Protection: 0
github-authentication-token-expiration: 2023-04-25 04:59:46 UTC

{
    "data": {
        "user": {
            "location": "Tochigi,Japan",
            "name": "Uchida Masatomo",
            "url": "https://github.com/ekzemplaro"
        }
    }
}

確認したバージョン

$ http --version
3.2.1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0