• Resolved Blutarsky

    (@blutarsky)


    Hello, I have followed the instructions step by step, and when testing REST API, I am getting 200 as return code, but returned data is pure HTML (looks like a web page). Wondering if some settings are wrong, if NGNIX is interfering (although I do have some settings in .htaccess) or if the call is badly coded.
    Any hint?

    Javascript code:

    function wordpressConnector(){
    
      // URL and params
      var root = 'https://mydomain.com/wp-json';
      var endpoint = '/jwt-auth/v1/token';
      var queryParams = '?username=SOMEUSER&password=APASSWORD';
       
      // parameters for url fetch
      var params = {
        'method': 'POST',
        'muteHttpExceptions': true
      };
       
      // call the API
      var response = UrlFetchApp.fetch(root + endpoint + queryParams, params);
      var data = response.getContentText(); // returns pure HTML webpage
      var code = response.getResponseCode(); // returns 200
      var headers = response.getHeaders();
    }

    returned headers:

    {
        "x-sucuri-cache": "MISS",
        "x-proxy-cache-info": "0 NC:000000 UP:SKIP_CACHE_SET_COOKIE",
        "x-cache-enabled": "True",
        "Transfer-Encoding": "chunked",
        "Set-Cookie": "wordpress_google_apps_login=xxxxxxxxxxxxxxxxxxxxxxxx; path=/; secure; HttpOnly",
        "Content-Security-Policy": "upgrade-insecure-requests;",
        "X-XSS-Protection": "1; mode=block",
        "X-Content-Type-Options": "nosniff",
        "x-proxy-cache": "MISS",
        "x-tec-api-version": "disabled",
        "X-Frame-Options": "SAMEORIGIN",
        "Content-Encoding": "br",
        "x-httpd-modphp": "1",
        "Connection": "keep-alive",
        "Vary": "Accept-Encoding",
        "Link": "<https://mydomain.com/?p=29989>; rel=shortlink",
        "host-header": "yyyyyyyyyyyyyyyyyyyyyyyyy",
        "Content-Type": "text/html; charset=UTF-8",
        "x-sucuri-id": "14012",
        "Date": "Wed, 12 Oct 2022 09:48:42 GMT",
        "Server": "Sucuri/Cloudproxy"
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Getting 200, but returned data is HTML’ is closed to new replies.