0

I am encountering the following error when making a REST request with Python.

Note: This API can help determine whether an individual address is up to date by typing individual address, first name, last name, etc.

Below is my code.

import requests
import json

req = requests.get('https://smartmover.melissadata.net/v3/WEB/SmartMover/doSmartMover
?t=1353
&id=428h8f8ghd8u
&jobid=1
&act=NCOA, CCOA
&cols=TransmissionResults,TransmissionReference, Version, TotalRecords,CASSReportLink,NCOAReportLink,Records,AddressExtras,AddressKey,AddressLine1,AddressLine2,AddressTypeCode,BaseMelissaAddressKey,CarrierRoute,City,CityAbbreviation,CompanyName,CountryCode,CountryName,DeliveryIndicator,DeliveryPointCheckDigit,DeliveryPointCode,MelissaAddressKey,MoveEffectiveDate,MoveTypeCode,PostalCode,RecordID,Results,State,StateName,Urbanization
&opt=ProcessingType: Standard
&List=test
&full=PATEL MANISH
&first=MANISH
&last=PATEL
&a1=1600 S 5TH ST                                               
&a2=1600 S 5TH ST                                               
&city=Austin
&state=TX
&postal=78704
&ctry=USA

Below is my error.

  File "C:\Users\testu\Documents\api.py", line 4
    req = requests.get('https://smartmover.melissadata.net/v3/WEB/SmartMover/doSmartMover
                                                                                        ^
SyntaxError: EOL while scanning string literal

Below is an excerpt from the documentation for REST JSON. (Link: http://wiki.melissadata.com/index.php?title=SmartMover_V3%3AREST_JSON)

REST Request

https://smartmover.melissadata.net/v3/WEB/SmartMover/doSmartMover
?t={Transmission Reference}
&id={License Key}
&jobid={Job ID}
&pafid={PAF ID}
&act={Actions}
&cols={Columns}
&opt={Options}
&List={List Name}
&comp={Company}
&full={Name Full}
&first={Name First}
&Middle={Name Middle}
&Namepre={Name Prefix}
&Namesfx={Name Suffix}
&last={Name Last}
&u={Urbanization}
&a1={Address Line 1}
&a2={Address Line 2}
&ste={Suite}
&pmb={Private Mailbox}
&city={City}
&state={State}
&postal={Postal Code}
&plus4={Plus4}
&ctry={Country}
&format={Format}

Below is an excerpt from the documentation for the request field. (Link: http://wiki.melissadata.com/index.php?title=SmartMover_V3%3ARequest)

Transmission Reference

  • Optional. This is a string value that serves as a unique identifier for this set of records. It is returned as sent.
    • REST: ?t = string
    • JSON: "TransmissionReference":"string"

Thanks for any help.

1
  • Your string to requests.get() is invalid Python. Commented Oct 26, 2018 at 16:50

1 Answer 1

1

You should use a dict to pass the query arguments:

url = 'https://smartmover.melissadata.net/v3/WEB/SmartMover/doSmartMover'
qargs = {'t': '...', 'id': '...', ..., 'format': '...'}
response = requests.get(url, params=qargs)

Se the documentation: http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls

The exception you get in your code is a python syntax error, BTW. A python string literal using ' or " is single-line. Python has support for multi-line string literals using """ / '''.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.