duncanjbrown / wp-api-client

A read-only Ruby client for the WordPress REST API (v2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoMethodError: undefined method `dig' for #<String:0x007fc17bf6a060>

abrambailey opened this issue · comments

After running @api = WpApiClient.get_client I see the following:

#<WpApiClient::Client:0x007fc17ecd9028 @connection=#<WpApiClient::Connection:0x007fc181aa91d8 @configuration=#<WpApiClient::Configuration:0x007fc17ec994f0 @endpoint="http://www.mysite.com/blog/wp-json/wp/v2", @embed=true>, @queue=[], @conn=#<Faraday::Connection:0x007fc181aa9110 @parallel_manager=nil, @headers={"User-Agent"=>"Faraday v0.12.2"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x007fc181aa8da0 @handlers=[Faraday::Response::RaiseError, FaradayMiddleware::ParseJson, Faraday::Adapter::Typhoeus]>, @url_prefix=#<URI::HTTP http://www.mysite.com/blog/wp-json/wp/v2>, @proxy=nil>>>
2.3.3 :009 > posts = @api.get('posts/')
ETHON: Libcurl initialized
ETHON: performed EASY effective_url=http://www.mysite.com/blog/wp-json/wp/v2/posts/?_embed=true response_code=301 return_code=ok total_time=0.195981
NoMethodError: undefined method `dig' for #<String:0x007fc17bf6a060>

Hi @abrambailey. Thanks for reporting. This error looks familiar: it's usually what happens when the WordPress API doesn't return anything. Could probably do with a better error message.

It looks like you're getting a 301 response from your server. Please could you find out where that 301 is pointing, and try to access the API at that address?