Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error about update_device_token() method #9

Open
crazygj opened this issue Mar 17, 2017 · 4 comments
Open

Error about update_device_token() method #9

crazygj opened this issue Mar 17, 2017 · 4 comments
Assignees
Labels

Comments

@crazygj
Copy link

crazygj commented Mar 17, 2017

When call method update_device_token(deviceId), it return

Traceback (most recent call last):
  File "/home/samsung/guojia/ArtikAutoTest/ArtikCloudSDK/CloudSDK.py", line 121, in <module>
    deviceToken = d.updateDeviceToken(deviceid)
  File "/home/samsung/guojia/ArtikAutoTest/ArtikCloudSDK/CloudSDK.py", line 110, in updateDeviceToken
    api_response = api_instance.update_device_token(ddid)
  File "build/bdist.linux-x86_64/egg/artikcloud/apis/devices_api.py", line 813, in update_device_token
  File "build/bdist.linux-x86_64/egg/artikcloud/apis/devices_api.py", line 891, in update_device_token_with_http_info
  File "build/bdist.linux-x86_64/egg/artikcloud/api_client.py", line 334, in call_api
  File "build/bdist.linux-x86_64/egg/artikcloud/api_client.py", line 157, in __call_api
  File "build/bdist.linux-x86_64/egg/artikcloud/api_client.py", line 376, in request
  File "build/bdist.linux-x86_64/egg/artikcloud/rest.py", line 224, in PUT
  File "build/bdist.linux-x86_64/egg/artikcloud/rest.py", line 174, in request
UnboundLocalError: local variable 'r' referenced before assignment

I found in file devices_api.py update_device_token_with_http_info() method, the header is defined as 'text/plain', it shoud be "application/json" right?

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['text/plain'])
@yujingwu
Copy link
Member

internal ticket DX-928

@jonathanpaek
Copy link

Internal Reference: DX-928 -> ALFA-7936

@crazygj thank you providing the error stacktrace. This will be resolved in our next release.

Background:
Requires an upstream fix to our swagger definition which incorrectly marks endpoint as consuming a body and sets wrong content-type. Note that PUT /devices/:deviceId/tokens should only require a path parameter (ie: deviceId). This should be "None".

This will apply a downstream fix into our SDK during next build where "None" content-type will default to "application/json" implicitly in subsequent build/release:
— lines 137

(reference: https://github.com/artikcloud/artikcloud-python/blob/master/artikcloud/rest.py)

Details of error:
rest.py — No control handling for content-type "text/plain" for http method "PUT" (rest.py). This fails to initialize a variable "r" that is used by the generated code.
— lines 137-169

(reference: https://github.com/artikcloud/artikcloud-python/blob/master/artikcloud/rest.py)

@vedupraity
Copy link

For me Its working now after replacing select_header_content_type(['text/plain']) with select_header_content_type(['application/x-www-form-urlencoded']) in file devices_api.py > [update_device_token_with_http_info()] > [# HTTP header Content-Type] at line number ~864.

Just curious to know if doing this is safe for now or what challenges or issues I might face later?

@yujingwu
Copy link
Member

@jonathanpaek please take a look. Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants