在graphql中解析jSON请求数据

时间:2018-09-25 06:21:07

标签: graphql rest-assured

请放心地尝试在图形查询中发布信息,并且无法正确查询。

请求:

"{query\":inventoryPositions(productRef:\"SKU_3\"){edges{node{onHand quantities{edges{node{ref quantity type}}}}}}}")

响应:

{
    "errors": [
        {
            "code": "400",
            "message": "Could not read document: Unexpected character ('q' (code 113)): was expecting double-quote to start field name\n 
        }
    ]
}

我也尝试过这种方法,但是不起作用:

{"query":"{inventoryPositions(productRef:\"SKU_3\"){edges{node{onHand quantities{edges{node{ref quantity type}}}}}}}"}

请帮助。

1 个答案:

答案 0 :(得分:0)

基本上,无论您在哪里发布变量,它都需要2个转义符

“ {\ n”                 +“ \” query \“:\” {inventoryPositions(productRef:\\“ SKU_3 \\” locationRef:\\“ locRef1 \\”){edges {node {onHand数量{edges {node {ref {number type}}} }}}} \“ \ n”                 +“}”

为我工作