Sorry, you need to enable JavaScript to visit this website.

You are here

MMSContent error 500

6 posts / 0 new
Last post

Penghao's picture
by Penghao

MMSContent error 500

Hi 

Thanks for ur last time help. I meet a new issue when sending mms. As request mmscontent should be like

{ "type": "image/jpeg", "filename": "image004.jpg", "payload": "/9j/4AAQSkZJRgABAQ..." }

However, I use python create a dict like this

{'type': 'image/png', 'filename': 'Telstra.png' ,'payload': 'iVBORw0KGgoAAAAN...} 

but the http response is error 500 

message":"Technical error : Execution of JS.PayloadSanityChecks failed with error: Javascript runtime error: \"TypeError: Cannot read property \"type\" from undefined.(PayloadSanityChecks.js:80)\" : An error has occurred while processing your request, please refer to API Docs for summary on the issue"

I just wonder if I make a mistake in setting the type.

Cheers

DeveloperSteve's picture
by DeveloperSteve

Hi servicedesk2

Thanks for reaching out, 

Which version of the SDK are you using? 

In the latest version from github (which uses openapi-generator) heres some sample code 

pic = {'type': 'image/png', 'filename': 'test.png', 'payload': base64_image}

send_mms_request = Telstra_Messaging.SendMmsRequest('from number', 'to number', 'subject', 'reply_request', 'notify_url', pic)

 

Penghao's picture
by Penghao

Hi Steven
Hi Steven I dont no if you can see the pic. My testing code is as follow: def mms(): fo=open(r"C:\Users\kane8\Desktop\1.jpg") content=base64.b64encode(fo.read())         kind=filetype.guess(r"C:\Users\kane8\Desktop\1.jpg")         mms={'type':kind.mime,'filename':fo.name,'payload':content}         print(mms)           api_instance = Telstra_Messaging.MessagingApi(Telstra_Messaging.ApiClient(configuration))         send_mms_request = Telstra_Messaging.SendMmsRequest("a","0450910822","a",False,"",mms)   try: api_response = api_instance.send_mms(send_mms_request) pprint(api_response) except ApiException as e: print("Exception when calling MessagingApi->send_mms: %s\n" % e) But the api response is 500 Cannot read property \"type\" from undefined. Could you plz find the mistake for me. Thanks

Penghao's picture
by Penghao

Hi Steven
Hi Steven Please disregard my previous comments. The issue has been solved. I figure out it's becase pic should not be a dict. It's a list [{pic1},{pic2}]. Anyway, thanks for your help btw i just wonder if the free account is not able to send mms. Cheers

Andrew's picture
by Andrew

Cannot send MMS using Python API

Hello Telstra people,

I'm attempting to send an MMS using the free developer account. I've already been able to send and receive SMS through the Telstra API. However, I can't get MMS sending to work.

My code is as below. Going by the response header from the Telstra server, it looks like the presented MMS data is not in a form the webpage expects, but I haven't been able to resolve this. Can you tell me what the problem is, please? It looks similar to the other question in this thread from 2 years ago.

Thanks - Andrew

Python script

import Telstra_Messaging
import base64 as base64

api_instance = Telstra_Messaging.AuthenticationApi()

auth_data  = {
'client_id': 'PP5....G3n', # client ID removed from pasted code
'client_secret': 'dYm...l5t', # client secret removed from pasted code
'grant_type': 'client_credentials',}

api_response = api_instance.auth_token(**auth_data)
configuration = Telstra_Messaging.Configuration()
configuration.access_token = api_response.access_token
messaging_api_instance = Telstra_Messaging.MessagingApi(Telstra_Messaging.ApiClient(configuration))

image_path = 'image001_small.jpg'

def get_base64_encoded_image(image_path):
    with open(image_path, "rb") as img_file:
        return base64.b64encode(img_file.read()).decode('utf-8')

image_base64 = get_base64_encoded_image(image_path)

MMS_content = {'type':'image/jpg', 'filename':image_path, 'payload':image_base64}

send_mms_request = Telstra_Messaging.SendMmsRequest(
    'Andy_Selby',
    '0409772573',
    'Theo',
    'False',
    'None',
    mms_content=MMS_content)

response = messaging_api_instance.send_mms(send_mms_request)
print(response)

Error traceback follows:

Traceback (most recent call last):
  File ".\send_mms_001.py", line 35, in <module>
    response = messaging_api_instance.send_mms(send_mms_request)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\api\messaging_api.py", line 424, in send_mms
    (data) = self.send_mms_with_http_info(send_mms_request, **kwargs)  # noqa: E501
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\api\messaging_api.py", line 505, in send_mms_with_http_info
    collection_formats=collection_formats)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\api_client.py", line 321, in call_api
    _preload_content, _request_timeout)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\api_client.py", line 152, in __call_api
    _request_timeout=_request_timeout)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\api_client.py", line 364, in request
    body=body)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\rest.py", line 274, in POST
    body=body)
  File "C:\Program Files\Python37\lib\site-packages\Telstra_Messaging\rest.py", line 227, in request
    raise ApiException(http_resp=r)
Telstra_Messaging.rest.ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 31 Jul 2020 01:05:58 GMT', 'Content-Type': 'application/json', 'Content-Length': '262', 'Connection': 'keep-alive'})
HTTP response body: {"fault":{"faultstring":"Execution of JS.PayloadSanityChecks failed with error: Javascript runtime error: \"TypeError: Cannot read property \"type\" from undefined. (PayloadSanityChecks.js:125)\"","detail":{"errorcode":"steps.javascript.ScriptExecutionFailed"}}}

 

Michelle's picture
by Michelle

Received: Cannot send MMS using Python API

Hi andrewselby,

Thanks for reaching out! I will have a look and see if I can troubleshoot your issue, in the menatime if any other devs here do spot the issue please post here :) Would love to get the community involved in helping you send an MMS! 

 

I can confirm that MMS are included as part of the free trial.

Log in or register to post comments