I am getting an error while pulling data from wordpress site using REST API over python












0















Anyone here can help me out with woocommerce REST API for Python? I just need to pull data from woocommerce website but its showing error.
The code is



from wordpress import API as WAPI
import time
import json

wpapi = WAPI(
url="https://xxxxk",
consumer_key="xxxxxx",
consumer_secret="xxxxxxx",
api="wp-json",
version="wp/v2",
wp_user="xxxx",
wp_pass="xxxxx",
oauth1a_3leg=True,
callback='https://xxxxxx',
creds_store="~/.wc-api-creds.json"
)

from woocommerce import API

wcapi = API(
url="xxxxxxxx",
consumer_key="xxxxxxx",
consumer_secret="xxxxxxxx",
wp_user="xxxx",
wp_pass="xxxx",
wp_api=True, # Enable the WP REST API integration
version="wc/v3", # WooCommerce WP REST API version
timeout=60
)

dataToFetch = 'products'
r = wcapi.get(dataToFetch).json()

with open(dataToFetch + '.json', 'w') as outfile:
json.dump(r, outfile,indent = 4, ensure_ascii = False)

with open(dataToFetch + '.json') as infile:
data = json.load(infile)
print(infile)


THE ERROR IS



Traceback (most recent call last):
File "C:UsersArsalanAppDataLocalProgramsPythonPython37MY WORK FILESREST API for building materials.py", line 63, in <module>
r = wcapi.get(dataToFetch).json()
File "C:UsersArsalanAppDataLocalProgramsPythonPython37libsite-packagesrequestsmodels.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjson__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 5 (char 4)
>>>


Please point out the mistake and provide a solution. Thanks in advance.










share|improve this question





























    0















    Anyone here can help me out with woocommerce REST API for Python? I just need to pull data from woocommerce website but its showing error.
    The code is



    from wordpress import API as WAPI
    import time
    import json

    wpapi = WAPI(
    url="https://xxxxk",
    consumer_key="xxxxxx",
    consumer_secret="xxxxxxx",
    api="wp-json",
    version="wp/v2",
    wp_user="xxxx",
    wp_pass="xxxxx",
    oauth1a_3leg=True,
    callback='https://xxxxxx',
    creds_store="~/.wc-api-creds.json"
    )

    from woocommerce import API

    wcapi = API(
    url="xxxxxxxx",
    consumer_key="xxxxxxx",
    consumer_secret="xxxxxxxx",
    wp_user="xxxx",
    wp_pass="xxxx",
    wp_api=True, # Enable the WP REST API integration
    version="wc/v3", # WooCommerce WP REST API version
    timeout=60
    )

    dataToFetch = 'products'
    r = wcapi.get(dataToFetch).json()

    with open(dataToFetch + '.json', 'w') as outfile:
    json.dump(r, outfile,indent = 4, ensure_ascii = False)

    with open(dataToFetch + '.json') as infile:
    data = json.load(infile)
    print(infile)


    THE ERROR IS



    Traceback (most recent call last):
    File "C:UsersArsalanAppDataLocalProgramsPythonPython37MY WORK FILESREST API for building materials.py", line 63, in <module>
    r = wcapi.get(dataToFetch).json()
    File "C:UsersArsalanAppDataLocalProgramsPythonPython37libsite-packagesrequestsmodels.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
    File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjson__init__.py", line 348, in loads
    return _default_decoder.decode(s)
    File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 5 (char 4)
    >>>


    Please point out the mistake and provide a solution. Thanks in advance.










    share|improve this question



























      0












      0








      0








      Anyone here can help me out with woocommerce REST API for Python? I just need to pull data from woocommerce website but its showing error.
      The code is



      from wordpress import API as WAPI
      import time
      import json

      wpapi = WAPI(
      url="https://xxxxk",
      consumer_key="xxxxxx",
      consumer_secret="xxxxxxx",
      api="wp-json",
      version="wp/v2",
      wp_user="xxxx",
      wp_pass="xxxxx",
      oauth1a_3leg=True,
      callback='https://xxxxxx',
      creds_store="~/.wc-api-creds.json"
      )

      from woocommerce import API

      wcapi = API(
      url="xxxxxxxx",
      consumer_key="xxxxxxx",
      consumer_secret="xxxxxxxx",
      wp_user="xxxx",
      wp_pass="xxxx",
      wp_api=True, # Enable the WP REST API integration
      version="wc/v3", # WooCommerce WP REST API version
      timeout=60
      )

      dataToFetch = 'products'
      r = wcapi.get(dataToFetch).json()

      with open(dataToFetch + '.json', 'w') as outfile:
      json.dump(r, outfile,indent = 4, ensure_ascii = False)

      with open(dataToFetch + '.json') as infile:
      data = json.load(infile)
      print(infile)


      THE ERROR IS



      Traceback (most recent call last):
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37MY WORK FILESREST API for building materials.py", line 63, in <module>
      r = wcapi.get(dataToFetch).json()
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libsite-packagesrequestsmodels.py", line 897, in json
      return complexjson.loads(self.text, **kwargs)
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjson__init__.py", line 348, in loads
      return _default_decoder.decode(s)
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 337, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 355, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 1 column 5 (char 4)
      >>>


      Please point out the mistake and provide a solution. Thanks in advance.










      share|improve this question
















      Anyone here can help me out with woocommerce REST API for Python? I just need to pull data from woocommerce website but its showing error.
      The code is



      from wordpress import API as WAPI
      import time
      import json

      wpapi = WAPI(
      url="https://xxxxk",
      consumer_key="xxxxxx",
      consumer_secret="xxxxxxx",
      api="wp-json",
      version="wp/v2",
      wp_user="xxxx",
      wp_pass="xxxxx",
      oauth1a_3leg=True,
      callback='https://xxxxxx',
      creds_store="~/.wc-api-creds.json"
      )

      from woocommerce import API

      wcapi = API(
      url="xxxxxxxx",
      consumer_key="xxxxxxx",
      consumer_secret="xxxxxxxx",
      wp_user="xxxx",
      wp_pass="xxxx",
      wp_api=True, # Enable the WP REST API integration
      version="wc/v3", # WooCommerce WP REST API version
      timeout=60
      )

      dataToFetch = 'products'
      r = wcapi.get(dataToFetch).json()

      with open(dataToFetch + '.json', 'w') as outfile:
      json.dump(r, outfile,indent = 4, ensure_ascii = False)

      with open(dataToFetch + '.json') as infile:
      data = json.load(infile)
      print(infile)


      THE ERROR IS



      Traceback (most recent call last):
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37MY WORK FILESREST API for building materials.py", line 63, in <module>
      r = wcapi.get(dataToFetch).json()
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libsite-packagesrequestsmodels.py", line 897, in json
      return complexjson.loads(self.text, **kwargs)
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjson__init__.py", line 348, in loads
      return _default_decoder.decode(s)
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 337, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:UsersArsalanAppDataLocalProgramsPythonPython37libjsondecoder.py", line 355, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 1 column 5 (char 4)
      >>>


      Please point out the mistake and provide a solution. Thanks in advance.







      python-3.x wordpress-rest-api






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 16:42







      Arsalan Ahmad Ishaq

















      asked Nov 22 '18 at 9:26









      Arsalan Ahmad IshaqArsalan Ahmad Ishaq

      114




      114
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427631%2fi-am-getting-an-error-while-pulling-data-from-wordpress-site-using-rest-api-over%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427631%2fi-am-getting-an-error-while-pulling-data-from-wordpress-site-using-rest-api-over%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy