为什么我的curl命令在plurasight api上收到错误的请求

时间:2019-03-26 15:21:19

标签: curl

卷曲“ https://app.pluralsight.com/player/api/graphql” -H“用户代理:Mozilla / 5.0(Windows NT 6.1; Win64; x64; rv:66.0)Gecko / 20100101 Firefox / 66.0” -H“接受: / “ -H”接受语言:en-US,en; q = 0.5“ --compressed -H”推荐人:https://app.pluralsight.com/player?course=python-scikit-learn-building-machine-learning-models&author=janani-ravi&name=28c11cee-cfc2-4fc5-b837-bbad57c682c9&clip=3&mode=live“ -H”内容类型:application / json; charset = UTF -8“ -H”来源:https://app.pluralsight.com“ -H”连接:保持活动状态“ -H” Cookie:AMCV_70D658CC558978FF7F000101“%” 40AdobeOrg = 1099438348“%” 7CMCIDTS“%” 7C17982“%” 7CvVersion“%” 7C2.1.0“%” 7CMCMID“%” 7C30770380242554347904237237541268829105“%” 7CMCAAMLH-1554174897“%” 7C3“%” 7CMCAAMB-1554217056“%” 7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBPy2Y7“%” 7“ 7” %“ 7CMCSYNCSOP”%“ 7C411-17989; profileScores = 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0; _psga = GA1.2.1800336076.1553570093; _psga_gid = GA1.2.7441612.1553570093; __cfduid = d2d2393bc58e937f38c2dyna_5351460; https://app.pluralsight.com/player; ajs_user_id =“%” 221f50ad3b-145b-431c-a537-f4906ad82f00“%” 22; ajs_group_id = null; ajs_anonymous_id =“%” 22246a8a14-e11b-4755-98e7-e34d40ae4dc4 _%“ 22; NPS_541 n = 1553570311749; PsJwt生产= eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoYW5kbGUiOiIxZjUwYWQzYi0xNDViLTQzMWMtYTUzNy1mNDkwNmFkODJmMDAiLCJpYXQiOjE1NTM1NzAzMTgsImV4cCI6MTU1NDE3NTExOH0.MvdGJoi-ZN5n6uqxlF36Y1_pPsD3pr59izn9nB9Fn-C; www-status-production = 1; _sdsat_v03-全局-用户ID = 1f50ad3b-145b-431c-a537-f4906ad82f00; __cfruid = 7c007c6a33fb1e75dde57993c487c7625d222857-15536​​12244; __cf_bm = 0388378ed8a25d31b61e6863c033c9702f7caac9-15536​​13222-1800-AVhbUzCcvCP2y0RpvU / 66f2 + Q1Y9O4HL / ldWr6eTp + Qxaubi80jB4ssxxCcZZYyY5mZ4; AMCVS_70D658CC558978FF7F000101“%” 40AdobeOrg = 1; s_cc = true“ -H” TE:拖车“ --data” {“”查询“”:“” \ n查询viewClip {\ n viewClip(输入:{\ n作者:\“” janani-ravi \“”, \ n clipIndex:3,\ n课程名称:\“” python-scikit-learn-building-machine-learning-models \“”,\ n includeCaptions:false,\ n语言环境:\“” en \“”,\ n mediaType:\“” mp4 \“”,\ n moduleName:\“” 28c11cee-cfc2-4fc5-b837-bbad57c682c9 \“”“ \ n质量:\”“ 1280x720 \”“ \ n}} {\ n网址{ \ n url \ n cdn \ n排名\ n源\ n},\ n状态\ n} \ n} \ n“”,“”变量“”:{}}“

1 个答案:

答案 0 :(得分:0)

由于查询有点错误,请检查引号转义和查询结构

比较您的查询:

{""query"":""\n query viewClip {\n viewClip(input: {\n author: \""janani-ravi\"", \n clipIndex: 3, \n courseName: \""python-scikit-learn-building-machine-learning-models\"", \n includeCaptions: false, \n locale: \""en\"", \n mediaType: \""mp4\"", \n moduleName: \""28c11cee-cfc2-4fc5-b837-bbad57c682c9\"", \n quality: \""1280x720\""\n }) {\n urls {\n url\n cdn\n rank\n source\n },\n status\n }\n }\n "",""variables"":{}}

工作正常:

{"query": "{\n  viewClip(input: {author: \"janani-ravi\", clipIndex: 3, courseName: \"python-scikit-learn-building-machine-learning-models\", includeCaptions: false, locale: \"en\", mediaType: \"mp4\", moduleName: \"28c11cee-cfc2-4fc5-b837-bbad57c682c9\", quality: \"1280x720\"}) {\n    urls {\n      url\n      cdn\n      rank\n      source\n    }\n    status\n  }\n}\n"}

美化:

{
  viewClip(input: {
    author: "janani-ravi",
    clipIndex: 3,
    courseName: "python-scikit-learn-building-machine-learning-models",
    includeCaptions: false,
    locale: "en",
    mediaType: "mp4",
    moduleName: "28c11cee-cfc2-4fc5-b837-bbad57c682c9",
    quality: "1280x720"
  }) {
    urls {
      url
      cdn
      rank
      source
    }
    status
  }
}

因此工作要求将是:

curl  "https://app.pluralsight.com/player/api/graphql" \
  --compressed \
  -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0" \
  -H "Accept: /" -H "Accept-Language: en-US,en;q=0.5" \
  -H "Referer: https://app.pluralsight.com/player?course=python-scikit-learn-building-machine-learning-models&author=janani-ravi&name=28c11cee-cfc2-4fc5-b837-bbad57c682c9&clip=3&mode=live" \
  -H "Content-Type: application/json;charset=UTF-8" \
  -H "Origin: https://app.pluralsight.com" \
  -H "Connection: keep-alive" \
  -H "Cookie: AMCV_70D658CC558978FF7F000101"%"40AdobeOrg=1099438348"%"7CMCIDTS"%"7C17982"%"7CvVersion"%"7C2.1.0"%"7CMCMID"%"7C30770380242554347904237237541268829105"%"7CMCAAMLH-1554174897"%"7C3"%"7CMCAAMB-1554217056"%"7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBpb2zX5dvJdYQJzPXImdj0y"%"7CMCOPTOUT-1553619456s"%"7CNONE"%"7CMCAID"%"7CNONE"%"7CMCSYNCSOP"%"7C411-17989; profileScores=0|0|0|0|0|0|0|0; _psga=GA1.2.1800336076.1553570093; _psga_gid=GA1.2.7441612.1553570093; __cfduid=d2d2393bc58e937f38c2d3a4b521460c51553570085; dyn_previousPage=https://app.pluralsight.com/player; ajs_user_id="%"221f50ad3b-145b-431c-a537-f4906ad82f00"%"22; ajs_group_id=null; ajs_anonymous_id="%"22246a8a14-e11b-4755-98e7-e34d40ae4dc4"%"22; NPS_a97f541b_last_seen=1553570311749; PsJwt-production=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoYW5kbGUiOiIxZjUwYWQzYi0xNDViLTQzMWMtYTUzNy1mNDkwNmFkODJmMDAiLCJpYXQiOjE1NTM1NzAzMTgsImV4cCI6MTU1NDE3NTExOH0.MvdGJoi-ZN5n6uqxlF36Y1_pPsD3pr59izn9nB9Fn-c; www-status-production=1; _sdsat_v03 - Global - User ID=1f50ad3b-145b-431c-a537-f4906ad82f00; __cfruid=7c007c6a33fb1e75dde57993c487c7625d222857-1553612244; __cf_bm=0388378ed8a25d31b61e6863c033c9702f7caac9-1553613222-1800-AVhbUzCcvCP2y0RpvU/66f2+Q1Y9O4HL/ldWr6eTp+Qxaubi80jB4ssIxZcqZfyJ5mZQuth6WTnZbbViThYiru8=; AMCVS_70D658CC558978FF7F000101"%"40AdobeOrg=1; s_cc=true" \
  -H "TE: Trailers" \
  --data '{"query": "{\n  viewClip(input: {author: \"janani-ravi\", clipIndex: 3, courseName: \"python-scikit-learn-building-machine-learning-models\", includeCaptions: false, locale: \"en\", mediaType: \"mp4\", moduleName: \"28c11cee-cfc2-4fc5-b837-bbad57c682c9\", quality: \"1280x720\"}) {\n    urls {\n      url\n      cdn\n      rank\n      source\n    }\n    status\n  }\n}\n"}'