复杂的请求有效负载-XML

时间:2018-08-09 15:14:29

标签: javascript xml xmlhttprequest

这是我正在拍摄的请求有效负载,不知道如何创建。 My goal

在我看来,该网站的请求有效负载是一个数组,并且我们只需要第一个(我想是因为那个0:)

里面有3个变量,最后一个也是数组。我继续创建类似的东西,但是……没有成功。

我的第二个想法是只看源代码,将源代码用于Request Payload之后,我将其作为代码:

var  pejlod = '[{"operationName":"withdrawal","variables":{"currency":"ltc","address":"1","amount":"1"},"query":"mutation withdrawal($address: String!, $amount: Float!, $currency: CurrencyType!) {\n  createWithdrawal(currency: $currency, address: $address, amount: $amount) {\n    id\n    amount\n    userFee\n    __typename\n  }\n}\n"}]';
var request = new XMLHttpRequest(),
url = 'https://api.WEBSITE.com/graphql',
data = pejlod;

request.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log("The request and response was successful!");
   }
};
request.open('POST', url, true);
request.setRequestHeader('Content-type', 'application/json');
request.setRequestHeader('x-access-token', "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjODZhZWEyZS1mYzg1LTQ3YTEtODllNC1kNWNjMjdmYmEwNDMiLCJpYXQiOjE1MzI4NTAzMDgsImV4cCI6MTUzODAzNDMwOH0.31vyw45woSRlC6qsDIEUZl_oEBl2CuXpEkruElfzuZI");
request.setRequestHeader('x-browser-hash','1dc017591e820df0b7fa02ded00e7f3f');
request.send(JSON.stringify(data));

这是我得到的结果:Again,it didn't work

希望有人能帮助我,我不认为我错过了我(第一个)的想法,但是我真的不知道该怎么做...

0 个答案:

没有答案