cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Newbie difficulties with JSON / cURL / and SendMMS

jnewman67
New Contributor

I've been trying for a couple hours to figure out how to send an MMS message (text and PDF) and have found some JSON code examples:

https://developers.sinch.com/docs/mms/api-reference/introduction/

and

https://developers.sinch.com/docs/mms/api-reference/sendmms/

but neither indicate how the cURL command should be formatted from the command line. 

here's are the different options (used in different combinations) for cURL I've tried so far (anonomized):

 

curl --user "application\myaccesskeyid:mykeysecret"

curl -X POST

curl -H "Authorization: Bearer myserviceplanid"

curl -d @batch.json (this is a file that contains the JSON code below)

 

the URL the documentation says to use is https://api.ci.mblox.com/ep/v2/

 

the JSON file contains the following minimum requirements per the documentation (again anonomized):

{
    "action": "sendmms",
    "service-id": "myserviceplanid",
    "to": "mydestphonenumber",
    "from": "mypurchasedphonenumber",
    "message-subject": "This is a JSON test.",
    "fallback-sms-text": "This is a JSON test.",
    "slide": [
        {

        "pdf": {
        "url": "{https://myimageurl.pdf}"
            },
        "message-text": "{This is a JSON test.}"
        }
   ]
}

 

the error i'm getting in response is

{
     "status": "failure",
     "error-code": "E100",
     "error-info": "Invalid request. Please make a valid JSON POST request with all the required variables."
}

anyone have any suggestions on what's missing or wrong with the above attempts?

Thanks in advance 🙂

4 REPLIES 4

Sam_Williams
Community Manager
Community Manager

Hello, thank you for reaching out!

 

To view a formatted curl example, you can visit the MMS JSON API reference and select the curl tab above the code sample. This is normally displayed on the right side of the page:

mms_send_curl.png

It looks like the JSON you provided was pretty well formatted. The issue may be with the headers. Note that, in order to authenticate with the MMS JSON API, you must include your account's API key (provided by your account manager) in the x-api-key header. Additionally, our sample has the Content-Type header set to application/json

 

If you have any other questions, or if these adjustments do not result in success, please feel free to respond to this post or send me a direct message with more information. I've also reached out to the team and asked if there are any other considerations that may have impacted the success of your API call. If there are any relevant findings, I'll either respond to this post or send a direct message with the details.

 

Thank you again for reaching out!

 

Sam Williams, Sinch Documentation Engineer

jnewman67
New Contributor

Maybe I should also ask the question - does SendMMS require a campaign (the documentation uses a CampaignID)?

Also, I tried inlining all the JSON code on the command line using the above information - that did not help either.

I was able to get a simpel SMS message to through using the Integrate API interface (and copying that to the command line), so stuff does go through.  just not SendMMS.

Hello again!

 

Requesting access to the API from your account manager is the primary documented prerequisite for using the MMS JSON API. Once the API is turned on, your account manager can provide your API Key.

 

I've asked the team for more clarity on the campaign ID requirement. I'll update this post once I get a response. Additionally, we'll make sure to review the corresponding documentation and make any required updates for clarity.

 

Thank you again for your question and feedback!

 

Sam Williams, Sinch Documentation Engineer

jnewman67
New Contributor

Okay, so using the format of the cURL example for the MMS JSON API link you sent yields a different error:  E104, and complains about the API-Key. 

Part of my difficulty might be all the slightly different names being given to "keys".

I have a Product ID, a Service Plan ID, an API Token, and Access Key ID, and Key Secret.

Seems WAY more complicated that other APIs I've used in the past.

The link you sent about "contacting account manager" does not take me to anywhere "manager" related.  I ended up finding a link for contacting my account manger (a generic email address) under Service APIs -> Configurations.

I'll send that email, see what that yields.