Created
June 15, 2013 12:34
-
-
Save tsega/5787976 to your computer and use it in GitHub Desktop.
Error when parsing JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#JSON::ParserError at / | |
#757: unexpected token at '<html><head><title>Apache Tomcat/6.0.24 - Error report</title><style><!--H1 {font-#family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-#serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-#color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-#family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-#serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> | |
#</head><body><h1>HTTP Status 404 - #/ws/api/store/product/9780942961522,9780942961485,9780942961478,9780942961430,9780942961423,9780942961447,9780942961416,97809429#61515</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> | |
#u>/ws/api/store/product/9780942961522,9780942961485,9780942961478,9780942961430,9780942961423,9780942961447,9780942961416,978094#2961515</u></p><p><b>description</b> <u>The requested resource | |
#(/ws/api/store/product/9780942961522,9780942961485,9780942961478,9780942961430,9780942961423,9780942961447,9780942961416, #97809429#61515) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.24</h3></body></html>' | |
#Error happens in, lib/web_service.rb the get_book_titles method line 104 | |
def get_book_titles(products) | |
titles = Array.new | |
unless products.blank? | |
pmids = '' | |
products.each do |product| | |
pmids += "#{product.product_id}," | |
end | |
pmids = pmids.chomp(',') | |
path = "/ws/api/store/product/#{pmids}" | |
response = http_get(path) | |
result = JSON.parse(response) | |
if result['response']['header']['status'] == 0 | |
result['response']['body'].each do |record| | |
titles << {:title => record['title'], :web_exclude_flag => record['webExcludeFlag'], :web_available => (record['webExcludeFlag'] == "N")} | |
end | |
end | |
end | |
titles | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment