ArgumentError: expected attributes to be able to convert to Hash, got [] - ruby-on-rails-5

I got this error in active-resource using grape gem with an entity.
I got this result on the browser
{"page":null,"per_page":null,"total_count":null,"total_pages":null,"medicines_being_taken":7,"medicines":[{"created_by":null,"chronic_state":false,"driving_alert":null,"dopping_alert":null,"pregnancy_alert":null,"special_medicine":true,"user_active_state":true,"prescribed_by_name":true,"breastfeeding_alert":null,"complete_medicine_id":null,"last_prescription_id":null,"photosensitivity_alert":null,"last_interaction_updated_at":null,"has_medicine_simposium_interactions":false}
But when I used rails application to fetch records from grape API I got this error
#<ArgumentError: expected attributes to be able to convert to Hash, got ["page", nil]>
The result is in the hash format.

Related

Scraping Twitter Data

I tried to scrape Twitter Data with an academic twitter API. The code worked for almost every case, even though there are a few cases, where it doesn't.
I used the code tweets <- get_all_tweets("#Honda lang: en -is:retweet", "2018-08-06T00:00:00Z", "2018-08-26T00:00:00Z", n = Inf)
but after scraping 4 pages of tweets, the following error occurred:
Error in make_query(url = endpoint_url, params = params, bearer_token = bearer_token, :
Too many errors.
In addition: Warning messages:
1: Recommended to specify a data path in order to mitigate data loss when ingesting large amounts of data.
2: Tweets will not be stored as JSONs or as a .rds file and will only be available in local memory if assigned to an object.
I actually don't get what the problem is because the code works even for cases with more than 35.000 Tweets. Therefore, I don't think the number of tweets is the reason.
`

Splunk REST API error handling with ouput_mode=json OR output_mode=csv

Using the Splunk REST API, i see that XML response will return search syntax errors or warnings.
if you select output_mode="csv" or output_mode="json" and the search had a syntax error, it simply finishes quickly and returns zero results.
Is there a way to change this behavior so that an error in syntax will return an error message instead of just sending back 0 results? I'd like to use JSON and not have to overhaul to support XML.
Searching API documents, I keep coming up empty.

Redis Session Storage Issue

I am a newbie in using Redis as my Cache storage.I am using it to store Cakephp Session in it.But when I store the session in it, It stores them as serialized Json. Now my question is How to store unserialized json in Redis using Cakephp ?
In programming i am able to use the session correctly but when i tried to get the data from cli it gives me something like shown in the update question. I think it is not pure serialized json as when i tried to unserialized it gives me error.
"s:3141:\"Config|a:1:{s:4:\"time\";i:1533905976;}session_start_time|s:19:\"2018-08-10 18:29:34\";Auth|a:1:{s:4:\"User\";a:19:{s:11:\"merchant_id\";i:16;s:4:\"name\";s:8:\"google\";s:5:\"email\";s:18:\"google#gmail.com\";s:8:\"username\";s:8:\"google\";s:7:\"balance\";s:11:\"92629148.57\";s:22:\"balance_deduction_type\";s:4:\"LIVE\";s:16:\"validate_txn_url\";s:67:\"http://";s:24:\"payment_verification_url\";s:49:\"http://";s:28:\"transaction_notification_url\";s:60:\"http://";s:11:\"sendsms_url\";s:45:\"http://";s:14:\"other_payments\";s:57:\"http://";s:9:\"client_ip\";s:0:\"\";s:7:\"created\";O:20:\"Cake\I18n\FrozenTime\":3:{s:4:\"date\";s:26:\"2017-08-04 04:41:55.000000\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:13:\"Asia/Calcutta\";}s:8:\"modified\";N;s:6:\"status\";s:6:\"ACTIVE\";s:4:\"type\";N;s:8:\"tds_rate\";d:0;s:12:\"api_key_hash\";s:32:\"b92c131e5bed70d3b596b1d0f3d7631b\";s:12:\"merchant_ips\";s:66:\"192.168.134.42,127.0.0.1,172.20.2.37,115.249.4.214,192.168.131.253\";}}MR|a:28:{s:11:\"merchant_id\";i:16;s:13:\"merchant_name\";s:8:\"google\";s:17:\"merchant_users_id\";s:6:\"5Adi01\";s:19:\"merchant_user_state\";s:5:\"DELHI\";s:24:\"merchant_user_branchcode\";s:3:\"B01\";s:16:\"merchant_channel\";s:6:\"RETAIL\";s:8:\"services\";s:14:\"GENERAL~HEALTH\";s:6:\"device\";s:7:\"WINDOWS\";s:20:\"merchant_lasttransno\";s:11:\"14507001061\";s:22:\"balance_deduction_type\";s:4:\"LIVE\";s:13:\"merchant_type\";N;s:24:\"payment_verification_url\";s:49:\"http:";s:7:\"sms_url\";s:45:\"http://";s:28:\"transaction_notification_url\";s:60:\"http:";s:16:\"validate_txn_url\";s:67:\"http://";s:14:\"other_payments\";s:57:\"http://";s:8:\"tds_rate\";d:0;s:10:\"retPanName\";s:13:\"PRITESH KUMAR\";s:5:\"rname\";s:19:\"Demo id 1 of Aditya\";s:8:\"rphoneno\";s:10:\"9654382580\";s:10:\"retEmailId\";s:27:\"satyendra.jain#skilrock.com\";s:10:\"retAddress\";s:74:\"K-230,VILLAGE KARAWAL NAGAR, Karawal Nagar, EAST DELHIDELHI, India, 110094\";s:14:\"retAddresscity\";s:10:\"EAST DELHI\";s:10:\"retStateId\";s:1:\"5\";s:16:\"diskSerialNumber\";s:22:\"pwdt-web-1332130123428\";s:11:\"merchantids\";s:13:\"5Adi01,5Adi01\";s:10:\"req_params\";a:21:{s:8:\"username\";s:8:\"google\";s:8:\"password\";s:8:\"12345678\";s:12:\"retailercode\";s:6:\"5Adi01\";s:5:\"state\";s:5:\"DELHI\";s:7:\"transno\";s:11:\"14507001061\";s:8:\"checksum\";s:9:\"962335274\";s:7:\"channel\";s:6:\"retail\";s:5:\"rname\";s:19:\"Demo id 1 of Aditya\";s:7:\"phoneno\";s:10:\"9654382580\";s:6:\"device\";s:7:\"WINDOWS\";s:7:\"service\";s:14:\"GENERAL~HEALTH\";s:7:\"product\";s:0:\"\";s:11:\"merchantids\";s:13:\"5Adi01,5Adi01\";s:12:\"diskserialno\";s:22:\"pwdt-web-1332130123428\";s:5:\"brand\";s:2:\"PW\";s:8:\"google\";s:9:\"insurance\";s:11:\"countercode\";s:6:\"5Adi01\";s:9:\"machineid\";s:9:\"BECZPULLS\";s:12:\"pw_sessionid\";s:0:\"\";s:7:\"apptype\";s:4:\"RPOS\";s:6:\"appver\";s:4:\"3.25\";}s:8:\"products\";s:0:\"\";}\";"

Outpan API C# POST Request

What does the Outpan server expect when posting data?
GET was giving me a json info that I was able to convert to an object.
Now when I'm giving information back just like the name:
https://api.outpan.com/v2/products/UPCCode/name?apikey=xxx
it will always not understand my information (error 400). Already tried sending the json back with additional info, "Foodname" and "name = Foodname"

eBay API addItem returns error - <Item.Country> is invalid or missing

I'm totally new to ebay api. I tried to use addItem api call, I stopped with this error.
`
eBay returned the following error(s):
37 : Input data is
invalid.Input data for tag <Item.Country> is invalid or
missing. Please check API documentation.
I've given all of their inputs and used their example (addItem code) only.
Site ID is 3 (UK) and currencyID="GBP"
See the link http://developer.ebay.com/devzone/xml/docs/reference/ebay/types/CountryCodeType.html.
Country Code for UK is GB.
So, your xml will be <Country>GB</Country>