Salesforce ServiceM8 Integration - api

We had already integrated Salesforce and ServiceM8. We have been pushing a custom object into servicem8 and creating a job.
This was working well before but not for last few days. We get the below error while posting.
Error:
{"errorCode":400,"message":"Bad Request. No data received in POST"}
Can you please identify what does this mean?
NOTE: We have been sending this in JSON format. We tried with the example that ServiceM8 given in the API document. That itself didn't get posted now.
Please assist, if there is any changes in the serviceM8 api.
I am passing the content type through header. Please find the sample request and response below.
Request===System.HttpRequest[Endpoint=https://api.servicem8.com/api_1.0/job/0bd2a066-8ac8-4d0c-83db-2deb78973ceb.json, Method=POST]
JSON String==={"status":"Completed","purchase_order_number":null,"job_description":"","job_address":"test, test, test, test, test","customfield_strata_number":"Yes","customfield_service_sheet_url":"SS2000420","customfield_salesforce_id":"012038","customfield_purchase_order_number":null,"customfield_notes_to_service":null,"customfield_notes_from_previous_service":null,"customfield_message_to_technician":null,"customfield_booking_notes":null,"customfield_booked_with_customer":"Yes","company_uuid":"15792888-b2f4-4538-a325-c3a58defaddb","badges":"[\"64cb190d-6a08-4ce2-ab08-56d8999c8a8b\",\"2aec7e2e-7370-42d0-9ea2-f16a859a2d1b\",\"a225a59f-b21f-4ea1-bce7-5e28ff2bd89b\",\"e71de9ce-8207-4bdd-a178-f05f35c675cb\",\"62795263-6867-45d8-868f-ab8cfbcf897b\",\"08b0cfa0-2d9c-438e-b7b0-ba41a437607b\",]"}
Response:
VF_PAGE_MESSAGE|{"errorCode":400,"message":"Bad Request. No data received in POST"}

Related

How to handle attachment and JSON data passed through form-data of postman to ESB flow?

Working on Mule 3.8
For emailService with attachment I have referred one of the earlier post (question) (how to upload a file and json data in postman) which has answer by #gce user. I followed the same. But now I am facing different issue. My JSON data is also getting considered as an attachment. How to avoid this inboundAttachment from getting attached to email. I am using simple SMTP component for sending emails.
Tried to use componenet attachment and triued to remove this attachment forcefully but it is still getting attached. #Gaurav Sharma How you avoid the JSON data from getting attached to email? This is the earlier post for reference
This is expected since you are sending json in form/data as seen in the image.
form/data will always send as attachment.
Try sending it as raw in the body part of postman:

Consuming TFS Web Hooks (Post via HTTP)

Is there a specific request format that the webhooks have? I am using the Pull Request Updated event, and I am trying to deserialize into a class, but I do not know what fields I will need. Is there a class or example of the request content details for the different events?
As far as I know, there isn't a generic template for the HTTP post request/response from TFS.
The TFS HTTP post JSON request/response format is based on the specific action.
For example, for the web hooks whenever a work item is updated.If I update a description field, I am getting one format and if I add a child work item, I am getting another format.
However for the specific event, you can check the response format, then get the useful information which you needed.
Please refer to Send JSON representation to a service for more information.
And at the end of the Q&A part there is a sample JSON.

Capturing Postman requests in a report

I was checking on Postman and newman and how to automate the api testing. I have checked on assertions and the report generations that show results of assertion failures and pass status. We can check the status code by writing a an assertion. But is there a way where in we can capture the request and response directly for an api and generate a report that shows (say) 3 apis were tested and the requests agve 200 for first call 201 fro second an d then 400 for third without writing any assertions. The overall result will show request url and corresponding response code for the api.
This will be helpful in a way when we run a collection and then can see a html report stating the response code corresponding to the request url.
Thank you all in advance for your patience reading and extremely helpful insight to the problem. Thank You.
this already exists in Postman, through its command line interface Newman.
Have a look here and here as well.
You'll be able to set options, depending on the kind of reports you want.
Personaly I can use newman in TFS and get JUnit style reports that fit for my continuous integration purpose. You can generate also HTML reports.
Check the different options.
To handle response data, have a look here :
This takes place in the Tests tab of the Postman request, though
You can obtain informations about HTTP code (responseCode.code), description (responseCode.detail), etc.
You can also parse the JSON body to get more information
var jsonData = JSON.parse(responseBody);
You can output this data in the console

How to read the headers of the REST API response using TRON and Alamofire

I am currently using Xcode8 and have built an app that make REST API calls using TRON and Alamofire.
I am successfully calling the API and getting back a response. This response BODY is being parsed into a model class that is structured to mimic the response body of the API call, and all of my properties are being populated with the correct values.
The new requirement I have now been given is to read some authentication information from the HEADER of the response. This information has been defined as a JSON Web Token. I can't seem to find any information on how to parse this information from the response HEADER using TRON or Alamofire.
Any insight, example, links, or comments will be greatly appreciated. Thanks in advance for any help.
I found the answer on this SO post.
And then I solved it in my project like this:
if let authorization = response.response?.allHeaderFields["Authorization"] as? String {
UserDefaults.standard.set(authorization, forKey: Constant.AUTHORIZATION_TOKEN)
}

POSTing to web service API in Objective C?

I'm writing one of my first apps for consuming a web service in Objective C, it's a Lighthouse API client. I'm able to execute all the GETs and XML parsing correctly and quickly, but I'm having extreme trouble trying to create a new ticket via POST (http://lighthouseapp.com/api).
I'm using ASIHTTPRequest.
I tried including the parameters on the URL (i.e. POST /projects/#{project_id}/tickets.xml?title=boo).
I've tried putting the ticket XML in the request body.
<ticket><title>boo</title></ticket>
Nothing is working. (server always sends a response back saying it needs a title) I'm very new to web services - am I missing something obvious?
I had a quick look at the Lighthouse API and here's how you go about creating a new ticket.
Request URL is http://{yourCustomURL}.lighthouseapp.com/projects/{ProjectID}/tickets.xml where {ProjectID} is a 5 digit number - in my case 72945.
Method is POST
Content type should be set to application/xml
Body should be in the format below. All fields are optional so I only included the title
<ticket> <assigned-user-id type="integer"></assigned-user-id> <body></body> <milestone-id type="integer"></milestone-id> <state></state> <title>Testing new ticket creation</title></ticket>
(sorry about the formatting of the code above, SO doesn't seem to like XML formatted code somehow?
This worked for me with a new ticket created under projectID 72945 - response received was 201 Created
If you want to make sure your POST request is working before diving into ASIHTTPRequest, download a Firefox add-on called POSTER from here. This will allow you to send an authenticated post request with all the fields above. Once you get that working, it should be a piece of cake to get ASIHTTPRequest to do the same.