diff --git a/lib/folio_request.rb b/lib/folio_request.rb index 2b903ba5..e0daefde 100644 --- a/lib/folio_request.rb +++ b/lib/folio_request.rb @@ -20,12 +20,12 @@ def get_json(path) end def get_cql(path, query) - path += "?query=#{query}" + path += "?query=#{CGI.escape(query)}" parse(authenticated_request(path)) end def get_cql_json(path, query) - path += "?query=#{query}" + path += "?query=#{CGI.escape(query)}" puts JSON.pretty_generate(JSON.parse(authenticated_request(path))) end @@ -86,6 +86,7 @@ def base_url end def make_path(path) + path = path.gsub(/\s/, '%20') path.start_with?('/') ? path.strip : "/#{path.strip}" end diff --git a/tasks/helpers/orders/po_lines.rb b/tasks/helpers/orders/po_lines.rb index f0c9134d..6260adeb 100644 --- a/tasks/helpers/orders/po_lines.rb +++ b/tasks/helpers/orders/po_lines.rb @@ -232,13 +232,13 @@ def lookup_holdings(obj) def holding_no_callnum(instance_id, location_id) query = "instanceId==#{instance_id} and permanentLocationId==#{location_id}" - results = @@folio_request.get_cql('/holdings-storage/holdings', CGI.escape(query).to_s) + results = @@folio_request.get_cql('/holdings-storage/holdings', query.to_s) results['holdingsRecords'][0]['id'] if results['totalRecords'] != 0 end def holding_with_callnum(instance_id, location_id, call_num) query = "instanceId==#{instance_id} and permanentLocationId==#{location_id} and callNumber==\"#{call_num}\"" - results = @@folio_request.get_cql('/holdings-storage/holdings', CGI.escape(query).to_s) + results = @@folio_request.get_cql('/holdings-storage/holdings', query.to_s) results['holdingsRecords'][0]['id'] if results['totalRecords'] == 1 end diff --git a/tasks/helpers/organizations/organizations.rb b/tasks/helpers/organizations/organizations.rb index 46be1d33..42c7f582 100644 --- a/tasks/helpers/organizations/organizations.rb +++ b/tasks/helpers/organizations/organizations.rb @@ -128,7 +128,7 @@ def determine_org_uuid(legacy_identifier, okapi_url) def organizations_id(code) response = FolioRequest.new.get_cql('/organizations/organizations', - "code==#{CGI.escape(code).dump}")['organizations'] + "code==#{code.dump}")['organizations'] begin response[0]['id'] rescue NoMethodError