Category : fetch

I’m getting error in response while sending file to adobe by fetch API. I’m getting error like:: {"cpf:inputs":{"documentIn":{"cpf:location":"InputFile0","dc:format":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}},"cpf:engine":{"repo:assetId":"urn:aaid:cpf:Service-1538ece812254acaac2a07799503a430"},"cpf:status":{"completed":true,"type":"","title":"For application/vnd.openxmlformats-officedocument.wordprocessingml.document mime-type The input file appears to be corrupted and cannot be processed.; transactionId=rg2xvsgT0KgnTk4L0cGR7PWMK20RVt5P","status":400,"report":"{"error_code":"CORRUPT_DOCUMENT"}"}} My code is: Here fileData is basically base64 of file and I’ve already check base64 by decoding before passing to method. adobeApiHIT(fileData, docMimeType) ..

Read more

I’m building a custom API endpoint for wordpress, and when trying to secure it with nonce I can’t get check_ajax_referer() to return anything but -1. I’m using fetch to call my API. This is my javascript front: var nonce = ‘<?php echo wp_create_nonce(‘wp_rest’); ?>’; … fetch(‘https://sdfsdf.dk/wp-json/bookings/v1/book/’, { method: "POST", headers: {"Content-type": "application/json","X-WP-Nonce" : nonce}, body: ..

Read more

Upon making a PUT request to my REST API, it returns a serialized response payload with a 400 Bad Request to the client. {‘vote’: [ErrorDetail(string=’Duplicate vote not allowed’, code=’vote_error’)]} (Pdb) c Bad Request: /api/v1/questions/3/ [15/May/2021 09:41:24] "PUT /api/v1/questions/3/ HTTP/1.1" 400 39 However when the browser gets the response back it returns: Failed to load resource: ..

Read more

So I have a method called get_offices() and it outputs data properly as shown below: Here is the function code: function get_offices(page_id = 1) { make_request(`https://sample-api.fleishmanhillard.com/offices/?page=${page_id}`) .then(response => { if (response.status >= 200 && response.status < 400) { return response.json(); } else { throw ‘There has been an error in the response status.’; } }).then((json_data) ..

Read more

using fetch in this login function: const baseUrl = "https://test.mydomain.it"; export const login = async (username: string, password: string) => { const body = "username=" + username + "&password=" + password; const response = await fetch(baseUrl + "/v4/login/", { method: "POST", body: body, headers: { "Content-Type": "application/x-www-form-urlencoded", "accept": "application/json", "X-CSRF-TOKEN": "" }, }); if (!response.ok) ..

Read more