Search code examples
pythonpython-2.7solrurllib2

Solr: getting error on url field while updating


I am trying to update url fields of my Solr documents but i am getting below error

HTTP Error 400: Bad Request

I think it is because of a url field

image_new_path = https://aaa.com/bbb/posts/post_fta6cueqq1497926075564.jpeg
req = urllib2.Request(url=solrPath + '/update/json?commit=true', data='[{"id":"' + docs['id'] + '","image":{"set":'+image_new_path+'}}]')

Is there are some special character which i have to change? If yes which one and how?

Solr error:

RequestHandlerBase

org.apache.solr.common.SolrException: Cannot parse provided JSON: Expected ',​' or '}': char=:,​position=41 BEFORE='[{"id":"189",​"image":{"set":https:' AFTER='//aaa.com/bbb/user'

Solution

  • The problem is ":" i have to add '\' before ':' to make it work. So now image path becomes

    https\://aaa/bbb